Section 1 - Instruction

Welcome to decision trees, yet another ML approach! Imagine you're a loan officer deciding whether to approve applications. You'd ask questions like "Good credit score?" then "High income?"

Decision trees work the same way - they ask yes/no questions to make predictions.

Engagement Message

Name one yes/no question you could ask when deciding whether to approve a loan?

Section 2 - Instruction

Decision trees split data by asking the most helpful question first. Think of it like playing 20 questions - you want each question to eliminate as many wrong answers as possible.

The tree learns which questions are most useful from training data.

Engagement Message

Why would asking "Is the sky blue?" be a terrible first question for loan approval?

Section 3 - Instruction

Let's build a tree for loan approval! Here's our training data:

High IncomeGood CreditLoan Approved
YesYesYes
YesNoNo
NoYesYes
NoNoNo

Engagement Message

Which feature seems more important for approval?

Section 4 - Instruction

To pick the best question, decision trees measure something called Gini impurity. It measures how "mixed up" the outcomes are after a split.

Pure groups (all Yes or all No) have Gini = 0. Mixed groups have higher Gini values.

Engagement Message

Would a group with 3 Yes and 3 No have high or low Gini impurity?

Section 5 - Instruction

Let's calculate! If we split by "Good Credit," we get:

  • Good Credit = Yes: 2 approved, 0 denied (pure group)
Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal