Understanding Titanic Survival Predictions with Decision Trees
Decision Tree:
- Supervised learning Algorithm
- Can do both Regression and Classification capabilities
- Inverted tree like structure with bunch of if-else statements
The Titanic dataset is one of the most famous case studies in data science. It captures passenger details such as age, sex, class, fare, and family aboard, along with whether they survived or not. In this post, we’ll walk through how a decision tree model uses these features to predict survival, and what the visualization reveals.
How the Decision Tree Works
Root node: “Was the passenger male?”
If female, survival chances are much higher. The tree then considers passenger class and fare to refine predictions.
If male, survival chances drop significantly, but age and family aboard (siblings/spouses) still play a role.
Each node in the tree shows:
Gini impurity: How mixed the group is (lower / purer).
Samples: Number of passengers in that group.
Values: Counts of non-survivors vs. survivors.
For example:
Female passengers not in 3rd class had a very high survival rate (174 survived vs. 12 did not).
Male passengers over age 9 had a much lower survival rate (505 did not survive vs. 96 survived).
Insights from the Model
Gender mattered most: Women had a much higher chance of survival.
Class shaped opportunity: 1st and 2nd class passengers fared better than those in 3rd class.
Children had better odds: Younger passengers, especially with family aboard, were more likely to survive.
Wealth played a role: Higher fares correlated with survival, likely tied to cabin location and lifeboat access.
Values in Nodes of the Model
- At the root node, the value
[617, 364]represents the total counts of passengers who did not survive (617) and those who survived (364). This split is based on the feature sex, and it includes both male and female passengers. Not survived (0):
Male: 521
Female: 96
Survived (1):
Female: 246
Male: 118
- At the pclass_3rd leaf node, the value
[96, 246]shows the distribution of survival among female passengers. Here’s the breakdown: - Not survived (0):
Female in 3rd class: 84
Female not in 3rd class: 12
Male in 3rd class: 310
Male not in 3rd class: 211
- Survived (1):
Female not in 3rd class: 174
Female in 3rd class: 72
Male not in 3rd class: 65
Male in 3rd class: 53
- At the final termination node, the value
[12, 174]represents female passengers who were not in 3rd class. Among them: 12 did not survive
174 survived

Comments
Post a Comment