A small, portfolio-ready machine learning project using the Titanic dataset.
The focus is interpretability + correct evaluation, not just accuracy.
Before modeling, I started with these assumptions:
- Women survived more than men
- Higher class → higher survival
- Younger passengers → higher survival
- Higher fare → higher survival (as a proxy for wealth)
Then I trained models to validate/refine those hypotheses with data.
- File:
Titanic-Dataset.csv - Common Kaggle-style Titanic dataset used for ML practice.
- Fill missing values:
Age→ medianEmbarked→ mode
- Drop
Cabin(too many missing values) - Encode categorical variables:
Sex→ binary (male=1,female=0)Embarked→ one-hot encoding withdrop_first=True
(baseline category becomesEmbarked_C)
- Trained Logistic Regression for probability-based predictions: [ P(\text{Survived}=1 \mid X) ]
- Evaluated using:
- Accuracy
- Precision
- Recall
- F1
- Confusion Matrix
- Default
predict()uses threshold = 0.5 - I also tested threshold = 0.4 using
predict_proba():- Improves recall and often F1 (tradeoff: more false positives)
- Printed coefficients (log-odds)
- Converted coefficients → odds ratios
- Added:
% Change in OddsOdds as % of Baseline
- Trained RandomForestClassifier on the same features
- Compared metrics at:
- default voting threshold
- threshold = 0.4 (using probabilities)
- Sex and Pclass were the strongest predictors.
- Age and family-related features (SibSp/Parch) were secondary.
- Fare had minimal independent effect once class was included (often redundant with
Pclass).
Summary conclusion:
“Survival was driven primarily by gender and class; age and family structure played secondary roles, while fare added little independent signal once class was accounted for.”
. ├── Titanic-Dataset.csv ├── titanic_model.py ├── README.md ├── requirements.txt └── LICENSE