Problems in the grading of the last assignment

Hi, in the last assigment, when I’m grading the assignment I receive this error
problem

The cell 11 is supposed to be this (where you have to build the compute_information_gain)

{moderator edit: code removed}

and when I run the next cell, which is

info_gain0 = compute_information_gain(X_train, y_train, root_indices, feature=0)
print("Information Gain from splitting the root on brown cap: ", info_gain0)

info_gain1 = compute_information_gain(X_train, y_train, root_indices, feature=1)
print("Information Gain from splitting the root on tapering stalk shape: ", info_gain1)

info_gain2 = compute_information_gain(X_train, y_train, root_indices, feature=2)
print("Information Gain from splitting the root on solitary: ", info_gain2)

UNIT TESTS

compute_information_gain_test(compute_information_gain)

I get this

I don’t know if that’s the cause behind my grading issue, although it doesn’t look like. But the code I wrote is just right, so I can’t get how this error in the test is raised.

I don’t know if that’s the cause behind my grading issue,

Yes, failing a unit test is a sure way to also fail the grader.

Please do not post your code on the forum. That’s not allowed by the community standards.
I have edited your message to remove the code.

Perhaps there is an error in your compute_entropy() function. Be sure you check all of the hints for that function.

My compute_entropy() function pass all the tests, so it doesn’t seem to be the problem. Also, it happens the same with the code from the hint. How is it possible to get a nan when you are making a normal numeric operation in Python?

Double check that you checking for length of input y in compute_entropy is not zero?

Hi @Marcos_Quintas_Perez

In the compute_entropy() function, the variable entropy is set to a float of value 0.0 in the template code that is already done for you. If you have changed the code there, and this variable entropy only exists inside the if code block, then the function would return NAN value when the input node has no samples.

Passing the unit tests does not prove your code is perfect.

Thanks, that was the actual reason of my problem