Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Healthcare Analysis: Heart Disease Prediction Pipeline

This repository contains a production-style machine learning pipeline that predicts the presence of heart disease from clinical measurements.
It is built for reproducible experimentation with:

  • DVC for stage orchestration and artifact lineage
  • MLflow for experiment tracking
  • scikit-learn for preprocessing, modeling, and evaluation

The pipeline target is binary classification: heart_disease (0 = absence, 1 = presence).

What The Product Does

Given a tabular dataset (data/raw/Heart_Disease_Prediction.csv), the project:

  1. Ingests raw source data into a reproducible working artifact.
  2. Cleans and standardizes the dataset.
  3. Creates domain-inspired derived features.
  4. Trains a Random Forest model in a preprocessing pipeline.
  5. Evaluates model quality and tracks runs in MLflow.

Pipeline Stages

The end-to-end workflow is defined in dvc.yaml.

  1. data_ingestion
    Input: data/raw/Heart_Disease_Prediction.csv
    Output: data/raw/heart_raw.csv
  2. data_preprocessing
    • Normalizes column names to snake_case
    • Removes duplicates
    • Encodes target labels to 0/1
    • Imputes missing values (median for numeric, mode for categorical)
      Output: data/interim/heart_cleaned.csv
  3. feature_engineering
    • Adds derived features such as:
      • cholesterol_age_ratio
      • bp_age_ratio
      • high_st_depression
      • low_max_hr
    • Performs stratified train/test split
      Outputs: data/processed/train.csv, data/processed/test.csv, artifacts/feature_summary.json
  4. model_building
    • Builds a preprocessing + model pipeline:
      • StandardScaler for numeric features
      • OneHotEncoder for categorical features
      • RandomForestClassifier
        Output: models/model.pkl
  5. model_evaluation
    • Calculates accuracy, precision, recall, f1_score, roc_auc
    • Saves confusion matrix plot
    • Logs params, metrics, and artifacts to MLflow
      Outputs: reports/metrics.json, reports/confusion_matrix.png, MLflow run records

Repository Structure

src/
  data_ingestion.py
  data_preprocessing.py
  feature_engineering.py
  model_building.py
  model_evaluation.py
  utils.py
params.yaml
dvc.yaml
requirements.txt

Configuration

All runtime settings are centralized in params.yaml:

  • Data paths and target column
  • Train/test split settings
  • Categorical feature list
  • Random Forest hyperparameters
  • MLflow tracking URI and experiment name

Quick Start

1. Create and activate a virtual environment

PowerShell:

python -m venv .venv
.\.venv\Scripts\Activate.ps1

2. Install dependencies

pip install -r requirements.txt

3. Ensure input data is present

Place the source CSV at:

data/raw/Heart_Disease_Prediction.csv

4. Run the full pipeline

dvc repro

How To Use

Re-run only one stage

dvc repro data_preprocessing

You can replace data_preprocessing with any stage name from dvc.yaml.

Tune the model

  1. Edit hyperparameters in params.yaml under model.random_forest.
  2. Re-run:
dvc repro

Inspect outputs

  • Model file: models/model.pkl
  • Metrics: reports/metrics.json
  • Confusion matrix image: reports/confusion_matrix.png
  • Feature metadata: artifacts/feature_summary.json
  • Stage logs: logs/*.log

Open MLflow UI

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

Then open http://127.0.0.1:5000 in your browser.

Example Metrics (Current Local Run)

From reports/metrics.json:

  • Accuracy: 0.7963
  • Precision: 0.7600
  • Recall: 0.7917
  • F1 Score: 0.7755
  • ROC AUC: 0.8764

Notes

  • This project is for data science and engineering workflows, not clinical diagnosis.
  • Reproducibility depends on pinned data location, params.yaml, and DVC stage definitions.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages