heart disease risk prediction.
An educational machine-learning workflow on the UCI Cleveland dataset — with leakage traps eliminated and small-sample caveats stated plainly.
overview
Heart Disease Risk Prediction is an educational ML workflow built on the UCI Cleveland dataset (303 angiography records). It covers exploratory analysis, leakage-aware pipeline preprocessing, cross-validation, model tuning, permutation importance, SHAP explainability, and an offline Persian/English Android app.
Why the live Lab runs Logistic Regression alongside this Random Forest case study: On 242 training rows, LogisticRegression(C=1.0) achieved virtually the same 5-fold CV ROC-AUC as the tuned Random Forest (0.903 vs 0.904) while exporting as a compact 4 KB closed-form formula (28 weights) with exact 5.2e-15 scikit-learn parity and additive Δz log-odds explanations for both /lab/heart/ and the offline mobile app.
problem
Small tabular clinical datasets (303 rows) are notoriously easy to overfit or accidentally leak during scaling and imputation before train/test splitting. This project fits every imputer, scaler, and encoder strictly inside the pipeline and pairs predictions with per-feature explanations.
data
- dataset — UCI Cleveland Heart Disease dataset (13 clinical & angiography inputs → 28 transformed features)
- split — Stratified 80/20 split: 242 training patients, 61 held-out test patients
With only 61 held-out test patients, a few records swing test AUC noticeably — 5-fold CV (~0.90) is the steadier benchmark.
method
Numeric features undergo median imputation and standardization; categorical features undergo mode imputation and one-hot encoding (handle_unknown="ignore") strictly inside scikit-learn's pipeline. In the Python/Streamlit study, a tuned Random Forest + SHAP explains non-linear interactions; in the browser Lab and Flutter mobile app, the exported 4 KB Logistic Regression formula provides exact closed-form inference offline.
results
Read these numbers with caution: 303 records from a single angiography cohort do not generalize clinically without external validation.
limitations
No external hospital validation; specialized angiography variables (ca, thal) are unavailable to the general public; and the uncalibrated sigmoid output reflects statistical similarity to the Cleveland cohort rather than diagnostic clinical probability.
Educational project only — not clinically validated and not intended for diagnosis or medical decision-making. Dataset: 303 records; external validation is required.