Skip to content

Titanic Survival Prediction

The Titanic project asks a single question: given what we know about a passenger — their age, sex, ticket class, and a handful of other attributes — can we predict whether they survived? It is the canonical entry point to supervised classification in data science. The dataset is small enough to understand completely, complex enough to reward careful feature engineering, and historically grounded so that your model's outputs are interpretable against real events. Every technique you apply here — handling missing data, encoding categories, building a classification pipeline, evaluating with more than just accuracy — transfers directly to real production problems.

Learning Objectives

  • Load and inspect a real dataset using seaborn and pandas
  • Identify and handle three different types of missing data (drop, impute, encode)
  • Engineer new predictive features from raw columns using domain knowledge
  • Build a full sklearn Pipeline that encapsulates preprocessing and model training
  • Train and compare Logistic Regression, Random Forest, and Gradient Boosting classifiers
  • Evaluate a classifier using confusion matrix, precision, recall, F1, and ROC-AUC
  • Identify which features drive predictions and explain them to a non-technical audience
  • Detect and analyse misclassified cases to understand where the model fails

Skills Covered

Skill Area What You Practice
Exploratory Data Analysis Distribution plots, survival rate breakdowns, missing value analysis
Feature Engineering Title extraction with regex, family size, bucketed age, fare normalisation
Handling Missing Data Median imputation, mode imputation, column dropping
Classification Logistic Regression, Random Forest, Gradient Boosting
Model Evaluation Confusion matrix, classification report, ROC-AUC, feature importance
sklearn Pipelines Combining preprocessing and model training into one reusable object

Prerequisites

Complete these topics before starting:

Week 01 - Pandas: DataFrame creation, .groupby(), .fillna(), .drop(), .apply() - Matplotlib and Seaborn: histograms, bar charts, heatmaps, count plots - NumPy: basic array operations, np.log1p()

Week 02 - Supervised vs. Unsupervised Learning - Train-Test Split and Data Leakage - Scikit-learn Workflow - Logistic Regression - Trees, Forests, and Boosting - Classification Metrics

Project Structure

File What It Covers
README.md Project overview, prerequisites, structure (this file)
dataset-guide.md Column reference, missing value summary, business context
eda.md Exploratory data analysis — distributions, survival rates, correlations
feature-engineering.md Dropping redundant columns, imputing missing values, creating new features
model-building.md Baseline, Logistic Regression, Random Forest, Gradient Boosting, tuning
evaluation.md Confusion matrix, ROC-AUC, feature importance, error analysis
interview-questions.md 8 project-specific interview questions with model answers

How to Use This Guide

Work through the files in order. Each file builds on the previous one. The code blocks are designed to run sequentially — if you copy them into a single Jupyter notebook from top to bottom, everything should execute without errors.

  1. Read dataset-guide.md first. Understanding the columns and what they mean historically changes how you approach feature engineering.
  2. Run the EDA code in eda.md. Do not skim this step. EDA is where you form hypotheses that drive your feature engineering decisions.
  3. Work through feature-engineering.md carefully. The quality of your features matters more than your choice of model algorithm.
  4. Train models in model-building.md. Start simple (Logistic Regression), then add complexity only if the simpler model underperforms.
  5. Evaluate critically in evaluation.md. Accuracy alone is not enough.
  6. After completing the project, read interview-questions.md and write your own answers before looking at the model answers.

Estimated Time

Section Estimated Time
Dataset guide 15 minutes
EDA 45–60 minutes
Feature engineering 60–75 minutes
Model building 45–60 minutes
Evaluation 30–45 minutes
Interview questions 30 minutes
Total ~4 hours

Loading the Dataset

import seaborn as sns
import pandas as pd

df = sns.load_dataset('titanic')
print(df.shape)  # Output: (891, 15)

No download required. Seaborn ships the Titanic dataset as part of the library. If you are working offline, load it once with an internet connection and then df.to_csv('titanic.csv', index=False) to save a local copy.


Next: Dataset Guide