Is there some declarative way with numpy arrays to get left_indices/right_indices? Looping works but feels like there should be way to just filter the matrix directly.
for i in node_indices:
if X[i][feature] == 1:
left_indices.append(i)
else:
right_indices.append(i)
Would have loved to see some examples after the assignment showing optimized methods for doing the task. I enjoy the challenge of building my own stuff but would also like to see “Here’s how you should have done it” after it’s done. Though I guess yay, more future self led projects.
With this sort of online course, it’s very difficult to manage the impact of publishing a reference solution without making it way too easy to pass the course without learning anything.