A tree-based model recursively partitions an input space into axis-parallel regions. Each leaf predicts a class by majority vote or a regression value by expectation. Training greedily chooses a feature and threshold that minimize partition cost, because optimal space partitioning is NP-complete. section 5.6
CART training centers on three decisions:
- Represent the data as X with n points and d features, then search feature j and midpoint threshold t among candidate thresholds. section 5.6
- Evaluate partition quality using impurity; the Gini index estimates expected classification error and becomes zero for a pure leaf. section 5.6
- Control tree depth while reducing impurity to limit underfitting and overfitting; entropy provides an alternative objective. section 5.6
From-scratch CART implementation
A Python implementation defines TreeNode and DecisionTreeClassifier classes, stores Gini statistics and child links, and includes a max_depth control. The accompanying workflow loads Iris data, splits training and test sets, and measures accuracy. section 5.6
Figure 5.14 CART decision tree algorithm pseudo-code
Use the CART pseudo-code to follow recursive tree construction and split selection. section 5.6


