A Flowchart Learned from Data
Split examples into purer groups
A decision tree predicts by following learned questions from a root node to a leaf. Each internal node tests a feature threshold or category. Training searches for splits that reduce impurity, a measure of how mixed the target labels are within child groups. A leaf stores the final class distribution or numeric prediction.
queue_depth > 70?
├── no -> error_rate > 0.08? -> ...
└── yes -> dependency_down?
├── no -> risk 0.63
└── yes -> risk 0.96
Trees naturally represent thresholds and interactions without feature scaling. The dependency_down question matters only after queue_depth > 70, an interaction created by the path itself.
from sklearn.tree import DecisionTreeClassifier, export_text
tree = DecisionTreeClassifier(max_depth=3, random_state=42)
tree.fit(X_train, y_train)
print(export_text(tree, feature_names=list(X.columns)))
Analogy: A tree is a troubleshooting runbook learned from examples: ask one question, then choose the next question based on the answer.
Tip: Print a shallow fitted tree with export_text and verify that its earliest questions use information genuinely available at prediction time.