Skip to content

What is a decision tree?

A decision tree is a model that learns a sequence of rules from data to assign a category or predict a numerical value for a case it has not seen before.

A decision tree is a model that learns a sequence of rules from data to predict a category or a numerical value. It works like a flowchart of questions: each internal node tests one attribute of the case, each branch represents an answer, and the final leaf contains the prediction. For example, a tree can use order value and merchandise type to estimate whether an order will need special handling. Its rules are learned from earlier examples with known outcomes rather than written by hand. A small tree lets a reviewer follow the path behind an individual prediction; a very large one is harder to inspect and can fit the data used to build it too closely. As the scikit-learn documentation explains, limiting depth or pruning branches can help control that complexity. Readability, however, does not guarantee correct predictions on new cases.

See also: OverfittingWhen a model learns the noise in its training data instead of the rule, and collapses on new data it has never seen.

Choosing the tree's size

During training, the model looks for splits that separate cases with different outcomes. A leaf containing cases from only one category is called pure, but purity on the training examples does not show that predictions for new orders will be reliable. This risk is called overfitting. Limiting the number of questions along a path, requiring a minimum number of examples per leaf, and removing branches after training are options to compare on held-out validation data.

In the scikit-learn pruning example, an unpruned tree reaches 100% accuracy on training data and 88% on test data. Those figures apply to that experiment only; they do not indicate what a company should expect.

Small changes in the data can also reshape a single tree substantially: Breiman describes this instability. Combining trees is an alternative, covered under ensemble learning; weigh both on the actual use case, because an ensemble loses the simplicity of a single tree's path.

An enterprise example

A company wants to identify orders for inspection before shipment. It uses past orders and inspection outcomes as examples, excluding information available only after shipment. The model flags cases for review; a staff member makes the final call. The project lead compares trees of different sizes on validation data, then counts missed problems and unnecessary checks on newer orders held out from training. These errors have different operational costs, so overall accuracy alone cannot settle the choice.

Why it matters for decision makers

Before buying, verify that the production model really is a single tree and request its exported rules (with depth and number of leaves), the data sources, results on cases not used for model selection, and the update procedure. A readable path describes how the model reached a prediction; it does not establish that the data is representative or the decision fair. The NIST AI Risk Management Framework recommends documenting test data, metrics, limitations, and risk assessments, as well as monitoring the system in operation. Explainability is therefore one part of evaluation and does not replace these checks.

Frequently asked questions

A tree uses one set of rules; a random forest combines predictions from multiple trees.

No. Its decision path can be inspected, but data quality, errors, and possible disparities in outcomes require separate checks.
  • OverfittingWhen a model learns the noise in its training data instead of the rule, and collapses on new data it has never seen.
  • Ensemble learningCombining the predictions of several models to obtain one more accurate than any single model on its own.
  • Explainable AI (XAI)Explainable AI comprises methods for explaining an AI system's results and workings, weighing each explanation's faithfulness, audience, and limits of use.

See it in the universe

If you need the AI in production, not in a demo, that is my job.

See AI integrations

Or write to me.