Log salary of 263 baseball players is predicted from Years in the major leagues and Hits last season. Growing: each node is split at the input and cutpoint that minimise the RSS of the two halves (8.3), here with the rules of R's tree() (a node needs 10 players, each half at least 5, and the split must cut the RSS by 1% of the root's). Pruning: for a penalty α the subtree minimising RSS + α|T| (8.4) is kept; as α grows, leaves disappear one weakest link at a time.
The full tree T0 is grown once on all 263 players. Every subtree shown is a member of the weakest-link sequence: at each step the internal node t with the smallest g(t) = (RSS(t) − RSS(Tt)) / (|Tt| − 1) is collapsed, and g(t) is the value of α at which that happens. Colours: log salary, from about 4 (dark) to 7.8 (light).
code/ch08_lab.py (RTree: fit, prune_path, prune_sequence) and R's tree(), prune.tree() in ch08_lab.R.