Something went wrong. Try again.
Heart attack risk classification with EDA, visualizations, and model evaluation
Something went wrong. Try again.
Files
- Jupyter Notebook 98%
- Python 2%
README.md
Heart Attack Risk Classification #
The project shows an end-to-end supervised ML workflow: data validation, EDA, visualizations, preprocessing, SVM and KNN model training, F1 and ROC-AUC evaluation, and saved model artifacts.
Project Highlights #
- Dataset: 303 patient records, 13 clinical features, binary
target - Data quality: validates schema, missing values, binary target, and duplicate rows
- EDA: target balance, feature correlations, age vs maximum heart rate, and target-wise heart-rate distribution
- Models: calibrated Support Vector Machine with RBF kernel and K-Nearest Neighbors
- Evaluation: stratified train/test split, 5-fold cross-validation, F1, ROC-AUC, precision, recall, accuracy, confusion matrix
- Engineering: reproducible package structure, CLI training command, saved
joblibmodel, tests
Repository Structure #
heart-attack-risk-ai-engineering/
data/
raw/Heart Attack Data Set.csv
processed/
models/
notebooks/
reports/
figures/
src/heart_attack_ai/
tests/
Setup #
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install --upgrade pip
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
.\.venv\Scripts\python.exe -m pip install -e .
Run Training #
.\.venv\Scripts\python.exe -m heart_attack_ai.train
Outputs:
reports/metrics.jsonreports/model_comparison.csvreports/figures/*.pngmodels/best_model.joblibdata/processed/heart_attack_clean.csv
Current Result #
After deduplication, the cleaned dataset has 302 rows. On the held-out stratified test split, the best model is selected by ROC-AUC, with F1 used as the main classification quality check.
| Model | CV ROC-AUC | Test ROC-AUC | Test F1 | Recall | Precision |
|---|---|---|---|---|---|
| Calibrated RBF SVM | 0.916 | 0.900 | 0.857 | 0.909 | 0.811 |
| KNN | 0.906 | 0.867 | 0.784 | 0.879 | 0.707 |
Best model: svm_rbf
The dataset is small, so the model should be presented as a learning and engineering project rather than a production medical decision system.
Notebook #
The executed notebook is available at notebooks/01_eda_and_modeling.ipynb.
Data Source #
Kaggle dataset: https://www.kaggle.com/datasets/pritsheta/heart-attack