Decision tree splits
Pick a feature and a threshold. Minimise Gini impurity to find the best split.
Pick a feature and a threshold. Minimise Gini impurity to find the best split.
A teacher has made-up records for 30 students: how many hours each one studied and slept before an exam, and whether they passed (blue) or failed (red). A decision tree predicts pass or fail for a new student by asking yes/no questions such as “Studied less than 4.5 hours?”.
The question: which single question splits the passes from the fails best? Then, with depth 2, which second question helps most?
A decision tree asks yes/no questions like “Study hours < 4.5?”. Each question splits the data into two groups, and each group predicts its majority label. A good question makes each group as pure as possible (mostly Pass or mostly Fail).
Gini impurity measures that mix: 0 means pure, 0.5 means a 50/50 jumble. The tree tries every feature and threshold and keeps the split with the lowest weighted Gini, then repeats on each side. That greedy search is fast, but each step only looks one move ahead.
Best single split: sleep hours < 5.85 (weighted Gini 0.328).
A decision tree asks yes/no questions like “Study hours < 4.5?”. Each question splits the data into two groups, and each group predicts its majority label. A good question makes each group as pure as possible (mostly Pass or mostly Fail).
Gini impurity measures that mix: 0 means pure, 0.5 means a 50/50 jumble. The tree tries every feature and threshold and keeps the split with the lowest weighted Gini, then repeats on each side. That greedy search is fast, but each step only looks one move ahead.
Things to try