Data Science · Chapter 31 of 43
Decision Trees
A DECISION TREE splits the data with yes/no questions on features. Very interpretable — you can literally read the rules.
Single deep trees overfit; usually paired with ensembles (random forest, gradient boosting).
Example 1 (python)
from sklearn.tree import DecisionTreeClassifier
m = DecisionTreeClassifier(max_depth=4).fit(X_train, y_train)
print(m.score(X_test, y_test))Output
0.83Limit depth to reduce overfitting.
Example 2 (python)
from sklearn.tree import export_text
print(export_text(m)[:200])Output
|--- feature_0 <= 5.0 ...Trees are inspectable.
Key points
- Yes/no splits on features.
- Very interpretable.
- Prone to overfit — control depth.
- Base for random forests and boosting.
💡 Note: Trees don't need feature scaling — one of the reasons they're so popular on tabular data.
