Machine Learning Model for Heart Attack Risk Prediction
A machine learning decision-support prototype developed for iHealth Edu that estimates heart attack risk from patient data and delivers the result through a Flask API.
Project Gallery

Project Overview
I developed this project as the machine learning decision-support component integrated into the live iHealth Edu website for healthcare workers. Model development used A. Panday's 2025 Heart Attack Prediction in Indonesia dataset from Kaggle, containing 158,355 observations and 21 predictors.
The workflow covers data preparation, class balancing, model comparison, evaluation, and inference deployment. Random Forest was selected for its leading accuracy and ROC-AUC, then serialized and served through a Flask REST API deployed with Docker on Ubuntu.
My Contribution
- Prepared the dataset by encoding five categorical features, scaling the predictors, creating a stratified 80:20 split, and applying SMOTE only to the training data.
- Trained and compared Random Forest, Linear SVM, K-Nearest Neighbors, and Logistic Regression, with hyperparameter tuning focused on F1-score.
- Selected Random Forest based on its accuracy and ROC-AUC, serialized the model and preprocessing artifacts with Joblib, and built a Flask REST API for inference.
- Deployed the inference service with Docker on Ubuntu and integrated its prediction output into iHealth Edu for healthcare workers.
This project gave me experience in building a machine learning workflow from data preparation to real product integration.
- Python
- Scikit-learn
- Pandas
- SMOTE
- Flask
- Docker
System Scope
- 158,355 observations
- 22 columns
- 21 predictors
- 5 categorical features
- No missing values
- Stratified 80:20 split
- SMOTE on training data only
| Model | Accuracy | Precision | Recall | F1-Score | ROC-AUC | Highlights / Notes |
|---|---|---|---|---|---|---|
| Random Forest[Selected] | 71.93% | 64.12% | 68.15% | 0.6607 | 0.8015 | Selected model: highest accuracy (71.93%) and ROC-AUC (0.8015) |
| Logistic Regression | — | — | — | 0.6618 | — | Highest compared F1: 0.6618 |
| K-Nearest Neighbors | — | — | 70.40% | — | — | Highest compared Recall: 70.40% |
| Linear SVM | — | — | — | — | — | Compared model with no metric added |
Selected model: highest accuracy (71.93%) and ROC-AUC (0.8015)
Highest compared F1: 0.6618
Highest compared Recall: 70.40%
Compared model with no metric added
Random Forest was selected because it produced the highest accuracy and ROC-AUC in the documented comparison.
This prototype supports risk assessment and does not provide a clinical diagnosis or replace medical judgment.
- Joblib model and preprocessing artifacts
- Flask REST API
- Risk class and probability
- Supporting factors
- Global feature importance
- Docker deployment on Ubuntu
- iHealth Edu integration for healthcare workers
