Assertion error in exercise 3

Can someone help with identifying what is causing the error. I have attached the screenshot of the error message and my code below.

{mentor edit: code removed}

Please do not post your code on the forum. That’s not allowed by the Community Standards. I’ve removed the code from your message.

“nan” means “not a number”. There is something wrong in your code that is causing something mathematically impossible.

Check your code and see if it’s possible you’re using a variable before its correct value is defined.

Also, look for issues like divide-by-zero.

It’s also possible that your compute_entropy() function doesn’t return the correct value for the unit tests used for compute_information_gain().

You can read what data is used in compute_information_gain_test() by opening the file from the notebook File → Open menu.

You may also debug your functions by adding some temporary print() statements to display the values of the calculations. Be careful that you remove any added print() statements before you submit for grading.