Heart Attack Risk Prediction Model
⚠️ Disclaimer: This model is built for educational/portfolio purposes only. It is not a medical diagnostic tool and must not be used to make real health decisions. Always consult a qualified physician.
A Logistic Regression model predicting heart attack risk (output: 0 = low risk, 1 = high risk) from patient clinical measurements.
Dataset
Trained on the Heart Attack Analysis & Prediction Dataset (Kaggle), 303 patient records with 13 clinical features.
Preprocessing
- Outlier removal via the IQR method on numeric features (
age,trtbps,chol,thalachh,oldpeak). - Categorical features (
sex,cp,fbs,restecg,exng,slp,caa,thall) one-hot encoded (drop_first=True). - Numeric features standardized with
StandardScaler, fit on the training split only.
Files
heart_attack_artifact.joblib: dict with{"model", "scaler", "numeric_features", "feature_names"}.heart-attack-analysis-prediction.ipynb: full notebook (EDA, preprocessing, modeling, tuning).
Usage
import joblib
import pandas as pd
from huggingface_hub import hf_hub_download
path = hf_hub_download(repo_id="KubraParmak/heart-attack-prediction-model", filename="heart_attack_artifact.joblib")
artifact = joblib.load(path)
model = artifact["model"]
scaler = artifact["scaler"]
numeric_features = artifact["numeric_features"]
feature_names = artifact["feature_names"]
# Build a row matching `feature_names`, scale numeric columns with `scaler`,
# then call model.predict(...) — see the Space's app.py for a full example.
Performance
Test accuracy: 0.90 (Logistic Regression, penalty='l2', chosen via GridSearchCV).
Live Demo
See KubraParmak/heart-attack-prediction-demo for an interactive Gradio demo.