Every decision tree, at every node, solves this same small problem thousands of times: given one feature and a binary label, which threshold splits the data best? A tree that re-scans the array for every candidate threshold is the version that makes training slow; the one that doesn't is a running count.
Write best_split(x, y). Given a 1-D array of feature values x and a same-length 0/1 label array y, find the threshold that minimises the weighted Gini impurity of the two children it produces.
$$\text{gini}(y) = 1 - p_0^2 - p_1^2 \qquad \text{weighted} = \frac{n_L}{n}\,\text{gini}(y_L) + \frac{n_R}{n}\,\text{gini}(y_R)$$
Candidate thresholds are the midpoints between consecutive distinct values of x — not between consecutive rows, and not at the values themselves. A threshold between two rows that happen to share the same x cannot actually separate them, so it is never a candidate.
Return (threshold, weighted_gini) for the best split. If y is already pure (a single class) or x has only one distinct value, there is no meaningful split: return None.
Build the architecture on a canvas: place the components, configure them, connect them into a data flow, and write a short reason for each one. The AI reviewer grades your design against a rubric written specifically for this problem.
Minimum 5 components · needs a wide desktop screen