Skip to content

Repository files navigation

🚢 Titanic Survival Prediction

Python Version MLflow Scikit-Learn License: MIT

A comprehensive End-to-End Machine Learning Pipeline for the classic Kaggle Titanic challenge.


📖 About The Project

This project provides a robust, reproducible machine learning pipeline to predict passenger survival on the Titanic. It goes beyond a simple script by incorporating software engineering best practices, rigorous experiment tracking with MLflow, and intelligent feature engineering.

🌟 Key Features

  • Advanced Feature Engineering: Extracted passenger titles, calculated family sizes, and engineered new features like FarePerPerson.
  • Experiment Tracking: Integrated with MLflow to track hyperparameters, metrics (accuracy), and artifacts seamlessly.
  • Hyperparameter Tuning: Explores multiple combinations of max_depth and n_estimators for a Random Forest model.
  • Automated Visualizations: Automatically generates and logs feature importance plots to MLflow.
  • Scalable Structure: Organized cleanly into logical folders (src/, notebooks/, models/, data/) for scale.

📁 Project Structure

├── data/                   # Raw and processed datasets (ignored by git)
├── models/                 # Saved model `.pkl` files (ignored by git)
├── notebooks/              # Jupyter notebooks for exploratory data analysis
├── src/                    # Source code for utility functions (if any)
├── train.py                # Main training pipeline and MLflow integration
├── feature_importance.png  # Generated chart of feature importance
├── requirements.txt        # Detailed project dependencies
└── .gitignore              # Files/folders to ignore in tracking

🚀 Getting Started

Prerequisites

You need Python 3.8+ installed on your machine.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/titanic-survival-prediction.git
    cd titanic-survival-prediction
  2. Create and activate a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt

💻 Usage

1. Training the Model

To run the pipeline, engineer features, and train the Random Forest models across the defined search space, simply run:

python train.py

This will output accuracy scores for different hyperparameter runs and save the best models to the models/ directory.

2. Viewing Experiments in MLflow

This project uses a local SQLite backend for MLflow tracking. To view your runs, metrics, and logged feature importance charts, start the MLflow UI:

mlflow ui --backend-store-uri sqlite:///mlflow.db

Then open your browser and navigate to: http://127.0.0.1:5000

MLflow UI
MLflow Experiment Tracking UI

MLflow Metrics
Detailed Metrics and Hyperparameters in MLflow

📈 Results & Visualizations

Our best Random Forest model achieved an impressive Accuracy of 0.843 on the validation set.

Below is the Feature Importance plot generated during the training process, highlighting which features contributed most to the model's predictions:

Feature Importance

🛠️ Built With


🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages