Project Overview: Heart Disease Prediction Pipeline
This project builds an end-to-end machine learning solution to predict the presence of heart disease in patients. It processes clinical datasets from four distinct geographical locations (Cleveland, Hungary, Switzerland, and Long Beach, VA) and steps through a structured data science workflow—from raw data cleaning to a serialized, ready-to-deploy final model.
Technical Stack: Languages & Frameworks
The project is built entirely within the Python ecosystem, leveraging industry-standard data science and machine learning libraries:
Python 3: The core programming language used for scripting (data.py) and modeling.
Jupyter Notebook (.ipynb): Used as the interactive development environment to document and run the step-by-step pipeline experiments.
Scikit-Learn (Sklearn): The primary machine learning framework used for:
Dimensionality reduction (PCA)
Feature Selection
Supervised Learning (Classification algorithms like Logistic Regression, Random Forests, or SVMs)
Unsupervised Learning (Clustering algorithms)
Hyperparameter Tuning (GridSearch/RandomizedSearch)
Pandas & NumPy: Used heavily in _01_data_preprocessing.ipynb and data.py for reading, cleaning, handling missing values, and manipulating the heart disease matrices.
Pickle (.pkl): Used to serialize and export the trained model (final_model.pkl) for downstream deployment or inference.
Project Pipeline & Architecture
The project is organized logically into sequential Jupyter notebooks, making it highly modular and easy to follow:
1. Data Preprocessing (_01_data_preprocessing.ipynb & data.py)
Consolidates raw clinical data from the Cleveland, Hungarian, Switzerland, and Long Beach VA databases.
Handles missing values (often denoted by ? in raw UCI files), imputes clinical attributes, and normalizes feature scales.
2. Dimensionality Reduction (_02_pca_analysis.ipynb)
Applies Principal Component Analysis (PCA) to reduce the feature space while retaining the maximum variance, helping to combat the curse of dimensionality and visualize patient clusters.
3. Feature Selection (_03_feature selection.ipynb)
Identifies the most statistically significant clinical features (such as cholesterol levels, maximum heart rate, age, and chest pain type) to improve model training efficiency and prevent overfitting.
4. Supervised Learning & Modeling (_04_supervised_learning.ipynb)
Trains multiple classification algorithms to predict the binary or multi-class presence of heart disease.
Evaluates models using metrics such as accuracy, precision, recall, and F1-score.
5. Unsupervised Learning (_05_unsupervised_learning.ipynb)
Explores hidden patterns, patient clustering, and anomalies in the medical data without using target labels.
6. Optimization & Serialization (_06_hyperparameter_tuning.ipynb)
Fine-tunes the best-performing classifier's hyperparameters to squeeze out maximum predictive performance.
Saves the final optimized state as final_model.pkl inside the models/ directory for production use.