Hi,

Regarding C2W4 practice lab exercise 2, I used the lines below to finish the function;

left_indices = np.argwhere(X_train[:,0] == 1).reshape(-1,).tolist()

right_indices = np.argwhere(X_train[:,0] == 0).reshape(-1,).tolist()

In the picture I have attached, my code seems to get the correct output but the answer keys says that it is incorrect. Although I was able get the answer using a different code, can I still understand why the above two lines do not work?

Thanks,

MJ

Hi MJ, the `root_indices`

pick which samples to consider, and you need to use it. Also, `root_indices`

do not always contains all indices, so you need to make sure the `left_indices`

and `right_indices`

only return indices that are in `root_indices`

.

I see, so the reason for the error is because I did not use `root_indices`

. I can see that if you want to select subset of the indices, the function should use the input given.

@rmwkwok there might be some issues with the unit tests for this lab. I was doing vectorized versions of the implementations and it was not happy.