Who belongs to which group? (decision tree, classification tree, regression tree)
In brief
A decision tree divides people step by step by yes/no questions (for example "age less than 12.5?") into ever more uniform groups. It predicts which group a person belongs to. If the target is a number with many values, it predicts the mean in each leaf (regression tree).
When
- The target is a group (2 to 8 groups) or a number, plus columns from which to predict (numbers or groups).
- At least about 50 cases with all details. Cases with gaps are left out.
How it works in Statable
- Run the card "Can something be predicted?". Under the result open the section "Decision tree: who belongs to which group?".
- Choose the target under "Which group should be predicted?" (or "Which number should be predicted?"), and the columns under "From which columns?".
- Click "Grow the tree". Statable calculates in the browser.
Reading the result
- The tree is shown as a list of "If …" branches and as a tree chart. At each end (leaf) are the predicted group and how many people end up there, for groups also how many of them are assigned correctly.
- Statable learns the tree on 70% of the people (training data) and tests it on the remaining 30% (test data, fixed split). Only the test data show whether the tree also works for new people.
- "How often is the prediction right?" compares the tree on the test data with guessing the most frequent group. It comes with the table of actual against predicted group. If the tree is no better than guessing, it has probably learned only chance features of the training data. For numbers the mean error is given against guessing the mean.
- The table "Importance of the columns in this tree" gives the share of each column in the splits. It holds only for this one tree: similar columns can push each other out.
- If the tree splits nowhere, the target cannot be predicted better with these columns than by guessing.
What is often misunderstood
Trees are unstable: with other people the tree often looks quite different. It describes what fits these data and shows no causes.
Reporting the result
Report: target and columns, the method (CART, splitting by the Gini measure) with the settings (minimum number of cases to split and per leaf, complexity parameter cp), the fixed split into training data (70%) and test data (30%), the number of leaves, the hit rate on the test data next to guessing the most frequent group (for numbers the mean error next to guessing the mean) and the most important columns. Also: the tree itself as a figure or list and the note that the importance holds only for this one tree. Method: Breiman, Friedman, Olshen & Stone 1984, Classification and regression trees.
The decision tree (CART, Gini measure; at least … cases per split, at least … per leaf, cp = …) was grown on 70% of the cases (n = …) and tested on the other 30% (n = …). It has … leaves. On the test data the prediction was right in … % of the cases (guessing the most frequent group: … %). The most important columns were … .
For specialists
CART as R rpart (method = "class") with the defaults: split by the largest Gini improvement, at least 20 cases to split (minsplit), at least 7 per leaf (minbucket), pruning by cost-complexity with cp = 0.01. Numbers are split at the midpoint between two values, groups as a two-way split of all levels.
Sources
Breiman, L., Friedman, J. H., Olshen, R. A. & Stone, C. J. (1984). Classification and regression trees. Wadsworth. Therneau, T. M. & Atkinson, E. J. (2023). An introduction to recursive partitioning using the RPART routines. Mayo Foundation.