Titanic Survival Prediction
A machine learning pipeline that predicts passenger survival on the Titanic, with feature engineering from names, family size and cabin data, plus missing-value imputation and a logistic regression model.
By Jawher Ennaceur
View on GitHub- Machine Learning
- Data Analysis
- Feature Engineering
- Classification
- Data Visualization
The Problem
Given passenger records (class, sex, age, fare, family, cabin, embarkation port), predict who survived the Titanic disaster. The data has many missing values (about 20% of ages and 77% of cabins) and several raw columns that are not directly usable by a model.
The Approach
I explored the data with survival bar charts, distribution plots and a correlation heatmap to see which features mattered. For feature engineering I extracted the passenger title from the name and grouped rare titles (officer, royalty), combined siblings/spouses and parents/children into a single FamilySize feature, and reduced cabin numbers to a deck letter mapped to a numeric scale. I filled missing ages with the median age per title, missing fares and cabins with the median per passenger class, and missing ports with the most common one, then label-encoded the remaining categorical variables and trained a logistic regression classifier.
Results
- Engineered Title, FamilySize and deck features from raw name, family and cabin columns
- Handled missing data with group-based imputation (age by title, fare and cabin by class)
- Wrote reusable preprocessing functions applied identically to the training and test sets
- Generated a prediction file in Kaggle submission format