Machine Learning
Titanic Survival Classification
A higher cross-validation score did not lead to better test predictions. I compared four classifiers on Titanic passenger data to examine how feature engineering and tuning affected survival predictions.
- Python
- scikit-learn
- Pandas
- NumPy
- Matplotlib
- Seaborn

Problem
Could passenger details help predict who survived the Titanic? The dataset contains missing ages and cabin information, and fewer survivors than non-survivors. A useful model needed to do more than predict the most common outcome.
Objective
Compare classifiers and feature sets, then measure how the selected model performed on passengers kept out of training and model selection.
Approach
I reserved 20% of the data for testing and compared four classifiers on the same five training folds. Missing-value handling and encoding stayed inside each pipeline, so each fold learned its preprocessing from training data alone. A majority-class baseline gave the models a simple result to beat.
Implementation
Testing whether extra features helped
I compared seven passenger attributes with an expanded feature set that included family size, solo-traveler status, fare per person, name title, and whether cabin information was available. Both versions went through the same model comparison.
Choosing before testing
I tuned the two leading candidates and selected the highest mean cross-validation score. Tuned Gradient Boosting with simple features won that comparison. I then evaluated it on the 179 reserved passengers, keeping the selection fixed even when the untuned comparator scored higher.
Looking beyond accuracy
The notebook includes a confusion matrix, ROC curve, and misclassified passenger examples. These show where the model made mistakes. A prediction function also applies the fitted pipeline to raw passenger rows.
Results
The selected model reached 83.70% mean cross-validation accuracy and correctly classified 145 of 179 test passengers: 81.01%, compared with 61.45% for the majority baseline.
The untuned comparator achieved 82.68% test accuracy. Tuning improved the cross-validation score but did not improve performance on this test split.
Survivor recall was 59.42%, meaning the selected model missed 28 of the 69 survivors. That limitation matters alongside the overall accuracy. These figures come from my saved rerun after correcting title extraction.
Challenges
This is a small historical dataset evaluated with one test split. Related passengers may appear in both partitions, and comparing many candidates can make the best cross-validation score optimistic. The probabilities are uncalibrated, and there is no external validation. The included CSV’s original download source is not documented.
Metrics
- Mean CV accuracy
- 83.70%
Five stratified training folds; fold standard deviation: 2.96 percentage points.
- Test accuracy
- 81.01%
145 of 179 held-out passengers; majority baseline: 61.45%
- Survivor recall
- 59.42%
Identified 41 of 69 survivors in the held-out test set.
Screenshots
