Skip to content
IT glossary
Data and MLUpdated December 3, 2026

Decision tree

Дерево решений

A machine learning model that makes a prediction by asking a series of questions about the input. Each answer sends the input down a branch until it reaches a final prediction, such as a category or a number.

Also known as: случайный лес, random forest

From a question to a prediction

A decision tree breaks a prediction into smaller decisions. At the root, it might ask whether a home has at least 100 square meters of floor space. One branch might then check the home's age, while the other checks whether it has parking. A node with no further question is a leaf. In regression, a leaf predicts a number, often the average target value of its training examples. In classification, it can predict the most common class or report the class proportions as probability estimates.

How the tree learns its questions

A standard binary tree tests candidate splits, such as floor_area <= 100, on labeled training data. It scores each split by how much it reduces impurity or prediction error compared with leaving the examples together. Classification trees commonly use Gini impurity or entropy; squared-error regression trees use the spread of target values around each node's mean. The two child scores are weighted by the number of examples in each child, so making one tiny group perfectly pure may not improve the split much overall.

Training repeats this process within each child until a stopping rule applies. The search is greedy: it chooses the best available split at the current node rather than searching for the best complete tree. Prediction is simpler than training: follow a single path through the learned rules and return the leaf's output.

Example: predicting a sale price

Floor area <= 100 m²?
├─ Yes → $280,000
└─ No: Home age <= 20 years?
   ├─ Yes → $460,000
   └─ No  → $390,000

A 120 m² home built 15 years ago gets a prediction of $460,000. So does a 150 m² home of the same age: both land in the same leaf. This is why a regression tree produces stepwise predictions rather than a smooth price curve.

When to use one and what to watch for

A shallow tree is a useful baseline for tabular data when you need to show exactly which rules led to a prediction. Ordinary threshold-based trees don't usually need numeric features to be standardized. Support for categorical inputs and missing values depends on the implementation.

A deep tree can fit quirks of the training data and perform poorly on new examples. Limit its depth, require enough examples per leaf, or prune branches after training; use validation data to decide how much complexity to keep. A random forest is not another name for a decision tree: it combines predictions from many randomized trees and typically has lower variance than a single tree.

What comes up in interviews

You may be asked to compare two candidate splits or diagnose a large gap between training and validation scores. Explain why the split score weights children by size, and why forcing a tree to be too shallow can cause underfitting rather than improve generalization.