MACHINE LEARNING • LESSON 9

Splitting Data

A Decision Tree works by splitting data into smaller groups using questions. Each split tries to make the groups more useful for making a prediction.

THE SIMPLEST IDEA

A split divides one large group of data into smaller groups.

The Decision Tree asks a question about a feature. The answer determines which group each data point belongs to.

01

What Does "Splitting Data" Mean?

Imagine that we have a group of students and want to predict whether they will Pass or Fail.

At the beginning, all students are mixed together.

STUDENT A Fail
STUDENT B Pass
STUDENT C Fail
STUDENT D Pass
STUDENT E Pass
STUDENT F Fail

The tree needs a way to separate these examples. It can ask a question such as:

POSSIBLE SPLIT Is Study Hours > 3?
02

One Question Creates Two Groups

Suppose the question is:

QUESTION Is Study Hours > 3?

The students are now separated into two groups.

NO Study Hours ≤ 3

Students who studied 3 hours or less.

YES Study Hours > 3

Students who studied more than 3 hours.

This is what we mean by a split.

A split takes one group of data and divides it into smaller groups based on a question.
03

Why Does the Tree Split the Data?

The goal is not simply to divide the data randomly.

The tree wants to create groups that are easier to classify.

For example, imagine these two groups:

GROUP A Mostly Fail
Fail Fail Fail Pass
GROUP B Mostly Pass
Pass Pass Pass Fail

These groups are easier to work with than one large mixed group containing many Pass and Fail examples.

A good split makes the resulting groups more organized and more useful for prediction.
04

Example: Study Hours

Let's use a small dataset.

STUDY HOURS RESULT
1 hour Fail
2 hours Fail
3 hours Fail
5 hours Pass
6 hours Pass
7 hours Pass

A natural split is:

Study Hours > 3?
LEFT GROUP ≤ 3 hours

Fail, Fail, Fail

RIGHT GROUP > 3 hours

Pass, Pass, Pass

This is an excellent split for this small dataset because each resulting group contains only one class.

05

Not Every Split Is Good

The tree could choose many different questions. But not every question creates useful groups.

For example, suppose we split using:

Study Hours > 1?

That would create:

GROUP A ≤ 1 hour

Fail

GROUP B > 1 hour

Fail, Fail, Pass, Pass, Pass

The second group is still mixed. So this split is less useful than:

Study Hours > 3?
The goal is not simply to split the data. The goal is to find a useful split.
06

The Tree Can Split Again

Sometimes one split is not enough.

After the first split, the tree can take one of the resulting groups and split it again.

FIRST SPLIT Study Hours > 3?
NO Mostly Fail
YES
SECOND SPLIT Attendance > 80%?
YES Pass
NO Fail

This process can continue as the tree grows.

07

How Does the Tree Choose a Split?

During training, the Decision Tree considers possible splits in the available features.

It compares the resulting groups and looks for a split that separates the target classes well.

STEP 1 Look at a Feature

Example: Study Hours.

STEP 2 Try a Split

Example: Study Hours > 3.

STEP 3 Check the Groups

Are the groups more organized?

STEP 4 Choose a Useful Split

Use the split that improves separation.

There are mathematical methods for measuring how good a split is. We will cover those ideas only when they become necessary.

08

A Real-World Example

Imagine a bank wants to classify transactions as Normal or Suspicious.

POSSIBLE SPLIT Is Transaction Amount > ₹50,000?
NO ≤ ₹50,000

Mostly normal transactions.

YES > ₹50,000

More transactions may need additional checking.

The tree could then split the high-value group again using another feature, such as location or transaction frequency.

09

Splitting Is How the Tree Grows

Every time the tree makes a useful split, it creates new branches.

START One large group
SPLIT 1 Two groups
SPLIT 2 Smaller groups
FINAL Leaf predictions

This repeated splitting is what creates the tree structure we studied in the previous pages.

10

Splitting Data in One Picture

ALL DATA Students
SPLIT Study Hours ≤ 3 Fail
SPLIT Study Hours > 3 Mostly Pass
REMEMBER THIS

Splitting data means dividing a group into smaller groups using a useful question.

A Decision Tree repeatedly searches for useful splits that make the resulting groups easier to classify.

Data Question Split Smaller Groups Prediction
QUICK CHECK

Check Your Understanding

What is a split? A way of dividing one group of data into smaller groups using a question.
Why split the data? To create groups that are easier and more useful for making predictions.
Is every split useful? No. A good split separates the classes better than a poor split.
Can the tree split again? Yes. A resulting group can be split again using another question.
NEXT TOPIC

Overfitting in Decision Trees

Next, we will learn why a Decision Tree can become too complicated, memorize the training data, and perform poorly on new data.