Hi I was wondering if somebody could help me out understanding the logic of this part of the lab.
def split_dataset(X, node_indices, feature):
"""
Splits the data at the given node into
left and right branches
Args:
X (ndarray): Data matrix of shape(n_samples, n_features)
node_indices (list): List containing the active indices. I.e, the samples being considered at this step.
feature (int): Index of feature to split on
Returns:
left_indices (list): Indices with feature value == 1
right_indices (list): Indices with feature value == 0
"""
# You need to return the following variables correctly
left_indices = []
right_indices = []
### START CODE HERE ###
for i in node_indices:
***if X[i][feature] == 1:***
left_indices.append(i)
else:
right_indices.append(i)
I dont quite understand this part " if X[i][feature] == 1:"
I get I am selectin features from the X array but I dont understand why I have to write both [i] and [feature].
I thought [i] would go all over the features in the array. I know I am missing something but I cant put my finger on it.
Thank you for helping this young fool