How to Build a Decision Tree on Mac & Windows
A decision tree is the most readable predictive model there is — a flowchart of yes/no questions. Here's how to grow one on Mac & Windows and keep it honest.
A decision tree predicts an outcome by asking a sequence of simple questions about the predictors — “is price above X? is the area below Y?” — splitting the data at each step. The result is a model you can read like a flowchart, which is why it's so popular when interpretability matters.
Grow it
- Open your data and choose Decision Tree.
- Pick the outcome (a category for classification, a number for regression) and the predictors.
- Read the tree — each split is the question that best separates the data at that point.
Keep it from overfitting
Left unchecked, a tree will keep splitting until it memorizes the training data — and then predicts new data poorly. The fix is pruning: Stratum uses cross-validation to cut the tree back to the size that generalizes best, so you get a model that's accurate and readable.
Predict with it
Add a predicted-column back to your data in one click. And when you need more accuracy than a single tree, ensembles — random forests and boosted trees — combine many trees; see Lesson 24. Full walk-through in Lesson 23.
Frequently asked questions
What is a decision tree used for?
Predicting an outcome — a category (classification) or a number (regression) — through a readable sequence of yes/no splits. It's prized when you need to explain why a prediction was made.
How do I stop a decision tree from overfitting?
Prune it. Stratum uses cross-validation to cut the tree back to the size that predicts new data best, rather than letting it memorize the training set.
What's the difference between a decision tree and a random forest?
A decision tree is one readable model; a random forest averages many trees for higher accuracy at the cost of interpretability. Start with a tree to understand the data, move to a forest for prediction.
Can a decision tree handle both categories and numbers?
Yes — classification trees predict a category, regression trees predict a number, and both can use numeric and categorical predictors.