[06 // Machine Learning]
Machine Learning Model for Heart Attack Risk Prediction
- Python
- Scikit-learn
- Pandas
- SMOTE
- Joblib
- Flask
- Docker

[01]
Overview
This risk-prediction prototype compares four binary-classification algorithms on 158,355 observations with 21 predictors.
A selected Random Forest model is packaged as a Flask inference service that returns a class, probability, supporting factors, and global feature importance.
[02]
My Contribution
- Prepared the dataset by encoding five categorical fields and applying MinMaxScaler.
- Created a stratified 80:20 split and applied SMOTE to the training partition only.
- Compared Random Forest, linear SVM, KNN, and Logistic Regression with RandomizedSearchCV focused on F1.
- Serialized the selected artifacts with Joblib and deployed the Flask service through Docker on Ubuntu.
[03]
Key Technical Notes
- The original data contains 158,355 rows, 22 columns, and no missing values.
- The stratified split produced 126,684 training rows and 31,671 test rows before training-only SMOTE balancing.
- Random Forest reached 71.93% accuracy, 64.12% precision, 68.15% recall, 0.6607 F1, and 0.8015 ROC-AUC.
- Logistic Regression produced the highest compared F1 at 0.6618, while KNN produced the highest recall at 70.40%; Random Forest was selected for its leading accuracy and ROC-AUC.
[04]
Visual Evidence


[05]
Tech Stack
- Python
- Scikit-learn
- Pandas
- SMOTE
- Joblib
- Flask
- Docker
[06]
Status & Link
Prototype with deployed inference service
Source repository or production deployment is private.