Problem with the function Get_Best_split in C2_w4

Hi all,
I have a problem with the last function of the Lab (Get_best_split).
I got the correct result with solution I implemented but It seems that it doesnt work for the final test:

“# UNIT TESTS
get_best_split_test(get_best_split)”

I ve already fixed my code to deal with a pure target variable or when the target is fully correlated with a feature… but there is still one more error, as bellow:


AssertionError Traceback (most recent call last)
in
3
4 # UNIT TESTS
----> 5 get_best_split_test(get_best_split)

~/work/public_tests.py in get_best_split_test(target)
149 node_indexes = [2, 3, 4]
150 result = target(X, y, node_indexes)
→ 151 assert result == 0, f"Wrong result. Expected 0, got {result}"
152
153 n_samples = 100

AssertionError: Wrong result. Expected 0, got 1

The get_best_split() function is rather straightforward.

Problems with get_best_split() are often due to defects in compute_information_gain().

Thanks a lot.

Fixed the problem!

It was in the get_best_split() function.
In the For loop, I made a mistake when storing the feature with higher Information Gain.

Fixed!
Thanks!