Wrong information gain error for assignment!


I have written a function for compute_information_gain(). I get all the expected values but I still get the following error:

Any thoughts/advice?

All the best,

“nan” means “not a number”. The value being returned by your compute_information_gain() function is not a numeric value, so the assert fails.

Is this perhaps a divide-by-zero error? If it is, I have trouble seeing where this comes from.


No, divide by zero gives you a “divide by zero” exception.
“nan” can also happens if you are missing a value from a function parameter or an array.

Hi @sunnyw8403,

I was wondering, in exercise 1, it asks to


Check whether you have followed them.


@Raymond, that’s an excellent point.

I recommend you read the hint section:

1 Like

Thanks for the help! I checked with my entropy function, and it seems to be alright…I followed the format in the hints. Is there anything else that could yield the “nan” error?