C2_W4 practice lab- value error in excercise 2

In exercise 2 to split the data into two sets, i am hetting the output but it is shown a value error.


Hey @VANI_M,
It’s a little bit difficult to figure out from the images where exactly the error lies, but it looks like you are trying to multiply 2 arrays or perform an element-wise operation on 2 arrays, that are not compatible with each other. As far as Exercise 2 is concerned, in which we are supposed to implement the split_dataset function, I don’t see the need of any such operation.

I hope this helps, but if this doesn’t help resolve your error, please DM your code to me.

Cheers,
Elemento

Hey @VANI_M,
I see that you have created multiple private threads to share the code with me. For future references, whenever a mentor asks you to share your code, you can simply DM the mentor, and work your way along that thread only. Multiple private threads is only going to create confusion for both, you and the mentor.

Now, the error lies in your implementation of the split_dataset function. You have essentially iterated over the length of the node_indices, whereas what you are supposed do is to iterate over node_indices. Here, the node_indices represents the indices of the samples that you are considering at any node.

Let me give an example to you. Let’s say that

node_indices = [1, 4, 5]

So, 1, 4 and 5 represent the indices of the samples that you are supposed to consider at a particular node. But you are iterating over

len(node_indices) = 3

Thus, you are considering the samples indexed by 0, 1 and 2. I hope this highlights the difference between the 2 implementations.

P.S. - You don’t need to call me Sir. I am also a learner just like you.

Cheers,
Elemento