Course 4, lesson 33 of 100, Ages 10+

Decision trees

Asking questions to reach an answer

Like I’m 5

A decision tree is like the game 'twenty questions'. Is it an animal? Does it fly? Is it big? Each answer narrows things down until you know.

The big idea

A decision tree is a model made of yes-or-no questions. Start at the top, answer a question, follow the branch, and keep going until you reach a leaf with the answer.

The tree learns its questions from examples, picking the ones that split the data most neatly. Trees are easy to understand, which is useful in places like banks or hospitals where people need to see why a decision was made.

Examples

  • Should I take an umbrella?: Is it cloudy? Is rain forecast? Then yes.
  • Animal guessing: Has feathers? Can it fly? Probably a bird.
  • Loan checks: Does the person have steady income? Any unpaid debts?

How it works

  1. Ask the best first question to split the examples.
  2. Follow the branch that matches the answer.
  3. Keep asking until you reach a leaf with the answer.

Check your understanding

How does a decision tree reach an answer?
Options: By asking yes-or-no questions in order; By rolling dice; By drawing pictures.
Answer: By asking yes-or-no questions in order. Each answer leads down a branch towards the final answer.
Why are decision trees popular for important decisions?
Options: People can see exactly why the answer was chosen; They are always correct; They never need data.
Answer: People can see exactly why the answer was chosen. You can follow the path of questions that led to the answer.

Remember

Decision trees answer by asking a chain of questions learned from examples.

Talk about it

Make a three-question tree to guess a friend's favourite animal.

Go deeper

Trees choose splits that reduce impurity, measured by Gini impurity or entropy. Combining many trees in random forests or gradient-boosted trees gives some of the strongest models for table-shaped data.