Wrong information gain error for assignment!

Hello,

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,
Sunny

“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.

Sunny

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

image

Check whether you have followed them.

Cheers,
Raymond

@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?