C2_W4_Decision_Tree Exercise 3

when I run the test - it passes the three features in the example; but the fourth test gives the below error. Not sure where to start with debugging.

Information Gain from splitting the root on brown cap: 0.034851554559677034
Information Gain from splitting the root on tapering stalk shape: 0.12451124978365313
Information Gain from splitting the root on solitary: 0.2780719051126377

AssertionError Traceback (most recent call last)
in
9
10 # UNIT TESTS
—> 11 compute_information_gain_test(compute_information_gain)

~/work/public_tests.py in compute_information_gain_test(target)
110 node_indexes = list(range(4))
111 result = target(X, y, node_indexes, 0)
→ 112 assert np.isclose(result, 0.311278, atol=1e-6), f"Wrong information gain. Expected {0.311278} got: {result}"
113
114 result = target(X, y, node_indexes, 1)

AssertionError: Wrong information gain. Expected 0.311278 got: 0.44902249956730633

I believe your code for compute_infomation_gain() is not using the node_indices variable correctly.

Or, maybe the issue is with how your code uses the feature variable.

Yep - that was it. Was finding it strange that it didn’t impact the first three values.
Thank you!

I have the same error. However, I still could not figure out how to solve this issue. Any thoughts?