Skip to content
✳AI UNIVERSITYBY COMMONJOBS
Machine Learning

What is a decision tree?

A decision tree predicts by applying a sequence of feature-based splits.

✳ Beginner◷ 5–10 min + practiceTEXT-BASED LEARNING

Start from zero. Learn the meaning, explore a worked example and practise in three short text lessons. No previous AI experience is needed.

Start here · beginner

02 · See it in action

Follow the steps

  1. Draw a two-question rule for a synthetic task.
  2. Fit a shallow tree and inspect its splits.
  3. Compare it with a deeper tree on held-out data.
  4. Look at the number of examples reaching each leaf.

Worked example

from sklearn.tree import DecisionTreeClassifier
x = [[10], [15], [40], [45]]
y = [1, 1, 0, 0]
m = DecisionTreeClassifier(max_depth=1, random_state=7).fit(x, y)
print(m.predict([[12], [42]]))  # [1 0]

Read the example once, then explain each part aloud in your own words. If it includes Python, you can understand the idea first and run the code later in a local Python environment. Code is shown as text; this page does not execute it.

Sign in to save your reading progress.

Sign in
LET’S TALK

Find your next step.

Share a little about yourself. We’ll get in touch.

COMMONJOBS AI
✦ GEN Z’S WAY OF LEARNING

Your next era.
Powered by AI.

Make your next 5 days count.
Join the CommonJobs AI Bootcamp.

5-DAY AI BOOTCAMP12 Oct 2026

WE START IN

00Days
00Hours
00Minutes
00Seconds
Join Now

Learn AI. Build your next chapter.