This document explains how four machine learning algorithms work using the same loan approval dataset:
| Feature | Description |
|---|---|
| Age | Applicant age |
| Income | Annual income |
| Approved | Loan approval result (1=Approved, 0=Rejected) |
Example:
| Age | Income | Approved |
|---|---|---|
| 25 | 30,000 | 0 |
| 35 | 70,000 | 1 |
| 45 | 90,000 | 1 |
| 23 | 25,000 | 0 |
| 40 | 60,000 | 1 |
Given:
Age = 30
Income = 1,000,000
Predict:
Approved = ?
We will compare:
Decision Tree learns a series of IF-THEN rules.
Example:
Income > 60,000?
|
+---+---+
| |
No Yes
| |
Reject Approve
The model starts at the root node and follows a path until reaching a leaf.
Find the best feature to split.
Example:
Age
Income
The algorithm determines:
Income > 60,000
creates the purest separation.
Split records.
Income <= 60,000
-> Mostly Rejected
Income > 60,000
-> Mostly Approved
Repeat recursively.
Income > 60,000 ?
|
Yes
|
Age > 30 ?
/ \
No Yes
Approve Approve
Customer:
Age = 30
Income = 1,000,000
Path:
Income > 60,000
ā
Approve
Prediction:
Approved
Unlike Decision Tree, Logistic Regression does not create rules.
Instead it learns a mathematical formula:
Score =
b0
+ b1 Ć Age
+ b2 Ć Income
Then converts the score into a probability.
Probability =
1 / (1 + e^-Score)
The model learns coefficients.
Example:
Score =
-5
+ 0.02 Ć Age
+ 0.00005 Ć Income
Customer:
Age = 30
Income = 1,000,000
Formula:
Score
=
-5
+ (0.02 Ć 30)
+ (0.00005 Ć 1,000,000)
=
45.6
Probability:
ā 100%
Prediction:
Approved
Logistic Regression always considers:
Age
AND
Income
simultaneously.
It cannot completely ignore a feature like a Decision Tree often does.
Random Forest is a collection of many Decision Trees.
Instead of:
1 tree
we build:
100 trees
200 trees
500 trees
Dataset
|
---------------------------------
| | | | |
Tree1 Tree2 Tree3 Tree4 Tree5
| | | | |
---------------------------------
|
Final Decision
Suppose:
Tree 1 -> Approve
Tree 2 -> Approve
Tree 3 -> Reject
Tree 4 -> Approve
Tree 5 -> Approve
Final result:
Approve
because:
4 votes > 1 vote
Customer:
Age = 30
Income = 1,000,000
Predictions:
Tree 1 -> Approve
Tree 2 -> Approve
Tree 3 -> Approve
Tree 4 -> Reject
Tree 5 -> Approve
...
Final:
Approved
Single tree:
May learn wrong rule
Random Forest:
Many trees reduce mistakes
CatBoost is a Gradient Boosting algorithm.
Instead of many trees voting independently:
Tree1
Tree2
Tree3
each tree learns from previous mistakes.
Initial prediction:
Customer A -> Reject
Actual:
Approve
Error detected.
Learns:
How can I fix Tree 1?
Learns:
How can I fix Tree 1 + Tree 2?
Tree1
+
Tree2
+
Tree3
+
...
+
Tree200
Tree 1
Accuracy = 70%
Tree 2
Fixes mistakes
Accuracy = 75%
Tree 3
Fixes remaining mistakes
Accuracy = 80%
...
Tree 200
Accuracy = 90%+
Customer:
Age = 30
Income = 1,000,000
Tree contributions:
Tree 1 -> +0.30
Tree 2 -> +0.20
Tree 3 -> +0.10
...
Final Probability
= 99%
Prediction:
Approved
CatBoost:
| Algorithm | Strategy |
|---|---|
| Decision Tree | One set of rules |
| Logistic Regression | One mathematical formula |
| Random Forest | Many trees vote |
| CatBoost | Trees correct previous mistakes |
| Algorithm | Uses Both Features? |
|---|---|
| Decision Tree | Not always |
| Logistic Regression | Always |
| Random Forest | Usually |
| CatBoost | Usually |
| Algorithm | Interpretability |
|---|---|
| Decision Tree | Excellent |
| Logistic Regression | Excellent |
| Random Forest | Medium |
| CatBoost | Low |
| Algorithm | Typical Performance |
|---|---|
| Decision Tree | Good |
| Logistic Regression | Good |
| Random Forest | Very Good |
| CatBoost | Excellent |
For the loan approval problem:
Learns IF-THEN rules
Example:
Income > 60k -> Approve
Learns a probability formula
Example:
Age and Income both influence approval
Many Decision Trees vote
Example:
200 trees decide together
Many trees learn sequentially
and fix previous mistakes
Example:
Tree 2 improves Tree 1
Tree 3 improves Tree 1 + Tree 2
...
A practical experimentation order:
1. Logistic Regression
2. Decision Tree
3. Random Forest
4. CatBoost
Then compare using 5-fold cross-validation and choose the model with the best balance between accuracy, interpretability, and maintainability.