Decision Tree Visualizer

The most explainable model in machine learning is just a stack of yes/no questions. Watch a real tree grow on 2D data: the questions on one side, the map they carve on the other, and a depth slider that shows exactly how trees overfit.

100% in your browser. Every change retrains the tree instantly.
Two classes of points. The tree must learn where one class ends and the other begins.
How many questions deep the tree may go. This is the main complexity dial, and it maps straight onto overfitting.
Randomly flips some labels, like messy real-world data. Raise it, then max the depth, and watch the tree carve boxes around pure noise.
–
Train accuracy
–
Test accuracy
–
Leaves
Dots are data (circles = train, rings = test). The shaded rectangles are the tree’s decisions: every point landing in a region gets that region’s color.
Grow the tree with the depth slider.
The same model as questions. Left branch = yes, right branch = no. Leaves show their class, sample count, and purity.
How a tree decides

About the Decision Tree Visualizer

Ask a series of yes/no questions, and at the end give an answer: that is a decision tree, the most human-readable model in machine learning. "Is the transaction over $500? Is it from a new device? Then flag it." This tool trains a real tree on 2D data and shows you both faces of the same model at once: the flowchart of questions, and the map of rectangular regions those questions carve out of the plane.

Experiments worth running

How the tree chooses its questions

At every node the algorithm tries every possible split on both features and keeps the one that leaves the two resulting groups as pure as possible, measured by Gini impurity (roughly, how mixed the labels are). Then it repeats inside each group, until it hits your depth limit or the groups are already pure. Nothing is hand-tuned here; the questions in the flowchart were all discovered from the data, which is exactly what happens in production trees.

Why this family matters

A single tree is rarely the most accurate model, but teams of trees dominate practical machine learning on tabular data: random forests average hundreds of them, and gradient boosting builds them one on top of another. Every one of those celebrated methods is made of exactly what you see here. Understand this page and the words "forest" and "boosting" stop being magic.

Common questions

How does a decision tree work in machine learning?

It asks a stack of yes/no questions about the features (is x bigger than 0.4?) and each answer routes toward a leaf that gives the prediction. This tool shows the same model two ways at once: the flowchart of questions and the map of rectangular regions those questions carve.

What is Gini impurity and how does a tree choose its splits?

At every node the algorithm tries every possible question and keeps the one that leaves the purest groups, measured by Gini impurity (how mixed the labels are). Nothing here is hand-tuned; every question in the flowchart was discovered from the data, exactly as in production trees.

How does tree depth cause overfitting?

Each extra level lets the tree carve smaller rectangles, which can trace real structure or memorize noise. Set label noise to 20% and depth to 8: training accuracy climbs while test accuracy sags as tiny boxes wrap individual mislabeled points. Then lower the depth and watch the test score recover.

Why do decision trees only draw horizontal and vertical boundaries?

Every question involves one feature at a time, so every split is axis-aligned. On the diagonal dataset you can watch the tree approximate a slanted boundary with a staircase of little rectangles, the tree family's signature limitation.

Why should I learn decision trees?

Because random forests and gradient boosting (XGBoost, LightGBM), which dominate practical machine learning on tabular data, are built entirely out of these trees. Understand one tree and those famous methods stop being magic.

Related tools