Hello,
I’ve been getting a weird result from the 3rd exercise. I get this despite having the correct output.
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-42-2a50df79e115> in <module>
9
10 # UNIT TESTS
---> 11 compute_information_gain_test(compute_information_gain)
~/work/public_tests.py in compute_information_gain_test(target)
104
105 result = target(X, y, node_indexes, 1)
--> 106 assert np.isclose(result, 0, atol=1e-6), f"Wrong information gain. Expected {0.0} got: {result}"
107
108 print("\033[92m All tests passed.")
AssertionError: Wrong information gain. Expected 0.0 got: nan
I tried to use the hint code, but the exact same error appeared. Then, I tried to copy the code snippet from public_tests.py to reproduce the error.
X = np.array([[1, 0],
[1, 0],
[1, 0],
[0, 0],
[0, 1]])
y = np.array([[0, 0, 0, 0, 0]]).T
node_indexes = list(range(5))
result = compute_information_gain(X, y, node_indexes, 1)
print(result)
assert np.isclose(result, 0, atol=1e-6), f"Wrong information gain. Expected {0.0} got: {result}"
But this code snippet passed and didn’t print the assertion error. So I am not sure what’s actually going on now. Can someone help me diagnose the issue?
Thank you very much for your help.
Yours sincerely,
LUIY0004