GQ / lab logES / EN
← Back to the log

2024

Titanic, feature engineering and Random Forest

Survival classification with feature engineering (titles, family, deck, ticket frequency) and a GridSearch-tuned Random Forest.

Titanic, feature engineering and Random Forest

Problem

Predict which passengers survived from their travel data.

Data

Kaggle's Titanic training set: 891 passengers with class, sex, age, family, ticket, fare, cabin and port. Included as `data/titanic.csv`.

Method

Group-wise imputation, title and surname extraction, family and deck features, mutual information, and a 216-combination, 3-fold GridSearch.

Result

Without data leakage, the Random Forest scores 81.6% on the hold-out (84.8% cross-validated), 3.9 points above the "women survive" rule. The original 98.9% came from computing family and ticket survival rates on the whole dataset.

Stack

  • Python
  • scikit-learn
  • pandas
  • Seaborn

Context

Course: Machine Learning I · 2024

View the code on GitHub ↗