Decision Tree (Part 1): Should You Play Basketball? Let the Decision Tree Tell You!(Practical Data Analysis 11)
Learn how decision trees use weather, temperature, and wind data to make decisions like playing basketball. Explore ID3 and C4.5 algorithms with practical examples!
Welcome to the "Practical Data Analysis" Series
Imagine a scene where a girl's mother introduces her boyfriend to her:
Daughter: Is he handsome?
Mother: He's quite handsome.
Daughter: Does he own a house?
Mother: He has one back home.
Daughter: Does he earn a lot?
Mother: He's doing well, his annual salary is in the millions.
Daughter: What does he do?
Mother: He's in IT, and works in data mining for an internet company.
Daughter: Sounds good, I’ll meet him.
In real life, we face various decisions, whether it’s choosing a boyfriend or picking fruits. We tend to make judgments based on our past experiences.
If we map out the logic behind these judgments as a diagram, we’ll find it’s essentially a tree structure. This is what we’re going to talk about today: decision trees.
How Decision Trees Work
A decision tree essentially summarizes our past experiences.
Let me give you an example of a dataset for playing basketball. If we want to go play basketball, we generally make decisions based on "weather," "temperature," "humidity," and "wind," ultimately leading to the question: Should we play basketball or not?
The diagram above is a typical decision tree. When creating a decision tree, we go through two main stages: construction and pruning.