# Decision Tree

*noun*

say it: **“dih-SIZH-un TREE”** **/dɪˈsɪʒən ˈtri/**

A model shaped like a flowchart that reaches its answer by asking a series of yes-or-no questions about an example.

## What is a **decision tree**?

A **decision tree** is a model that guesses by asking a chain of yes-or-no questions about the features, like a
flowchart: "over 157.5 grams?", then "red?". Each path ends at a leaf that holds the answer. It learns which questions
to ask from the training examples, and you can read them.

```python
from sklearn.tree import DecisionTreeClassifier, export_text
fruit = [[120, 1], [130, 1], [125, 0], [135, 0], [180, 0], [185, 0], [190, 0]]   # grams, red (1) or not
names = ["apple", "apple", "lemon", "lemon", "orange", "orange", "orange"]
tree = DecisionTreeClassifier(random_state=0).fit(fruit, names)
print(export_text(tree, feature_names=["grams", "red"]))
# |--- grams <= 157.50
# |   |--- red <= 0.50
# |   |   |--- class: lemon
# |   |--- red >  0.50
# |   |   |--- class: apple
# |--- grams >  157.50
# |   |--- class: orange
```

## In a sentence

- “You can print a **decision tree** and follow its questions by hand.”
- “The **decision tree** first asked whether the fruit weighed more than 157.5 grams.”

Level: Apprentice · [More AI Basics terms at this level](https://www.ask-codey.com/glossary?category=ai&level=2)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/decision-tree
