Getting a couple errors in C2_W4_Decision_Tree_with_Markdown (with Right Answer)

Getting a couple errors.
Looks like I am getting right answers but the function that checks the output is saying I am getting something else.

Examples


The printed statement “Best feature to split on: 2” was a result of running your get_best_split function on X_train, y_train, and root_indices. The test that is raising the first assertion error is trying out your code with different input values and expecting a return value of 2, but instead your function is returning a value of zero.

I’m also getting the wrong information gain in the unit tests. Expected 0.0 got: nan.
I’ve determined it’s when all of the samples get put into one branch and none in the other, but haven’t figured out how to fix it. Any hints?

Hi @rubberduck203 ,

It could be the compute_entropy() is not returning the correct value, so check the logic there. You can put a print statement in the compute_infomation_gain() to check the value of all the variables used in the information_gain calculation.