Selected topic
Decision Trees
Prefer practical output? Use related tools below while reading.
=====================================
A decision tree is a popular machine learning algorithm used for classification and regression tasks. It's a simple, intuitive model that works by recursively partitioning the data into smaller subsets based on their features.
Suppose we want to predict whether someone will buy a car based on their age and income. Our dataset looks like this:
| Age | Income | Bought |
| --- | --- | --- |
| 25 | 50000 | Yes |
| 30 | 60000 | No |
| 28 | 40000 | Yes |
| ... | ... | ... |
We create a decision tree with the following structure:
+---------------+
| Age |
+---------------+
|
|
v
+---------------+ +---------------+
| Income < 50000 | | Income >= 50000|
+---------------+ +---------------+
| |
| |
v v
+---------------+ +---------------+
| Age <= 30 | | Age > 30 |
+---------------+ +---------------+
| |
| |
v v
+---------------+ +---------------+
| Yes (Bought) | | No (Not Bought)
+---------------+ +---------------+In this example: