Decision Tree Explorer

Decision trees classify data by asking a sequence of yes/no questions — "is x less than 4.2?" — splitting the plane into axis-aligned regions. Press Step to grow the tree one split at a time and watch accuracy improve.

Tree Visualization untrained
Class A Class B split boundary misclassified point
Controls
Max depth
Splits shown
0
Leaves
Tree depth
Train accuracy
How it works: At each step the algorithm tries every possible vertical and horizontal split and keeps the one that best separates the classes, measured by Gini impurity — how mixed a region still is. It repeats inside each region until the depth limit, a pure region, or too few points. Deeper trees fit the training data better but can memorize noise (overfitting) — compare depth 3 vs depth 5 on the same data.
Splits (in the order the tree adds them)
What's happening here? A decision tree is like a game of twenty questions. Each split carves the plane along one axis — first the big separation, then finer ones inside each region. Points with a ring around them are misclassified by the current tree; watch them disappear as you add splits. This greedy "best split at each step" strategy is exactly what libraries like scikit-learn implement under the hood.