Hybrid Voting Classifier–Based Heart Disease Prediction System
Research-Oriented | Hybrid ML Model | FastAPI Deployment
This repository contains the implementation aligned with an IEEE-published research paper on heart disease prediction using hybrid machine learning models.
🔗 https://ieeexplore.ieee.org/document/11081197
Cardiovascular diseases are among the leading causes of mortality worldwide. Early and accurate detection using clinical parameters can significantly improve patient outcomes and preventive care.
This project implements a Hybrid Machine Learning System based on a Voting Classifier, integrating multiple supervised learning algorithms to enhance prediction accuracy, robustness, and generalization. The trained hybrid model is deployed through a FASTAPI-based web application for real-time cardiac risk prediction.
✔ Design a Hybrid (Ensemble) Machine Learning Model ✔ Compare individual classifiers with a Voting Classifier ✔ Handle class imbalance using SMOTE ✔ Perform EDA, correlation analysis, and statistical visualization ✔ Deploy the final model using FASTAPI ✔ Maintain strict alignment with the IEEE research paper and presentation
| Attribute | Description |
|---|---|
| File | heart_1.csv |
| Records | ~900 |
| Features | Clinical & diagnostic parameters |
| Target | HeartDisease (0 = No, 1 = Yes) |
This dataset is retained in the repository for reproducibility and reference.
- Records: ~3200+
- Features: 12–15 clinically relevant attributes
- Used for: final hybrid model training
- Status: Intentionally excluded from GitHub via
.gitignore
This ensures a lightweight repository while preserving research-grade experimentation.
- Age
- Sex
- Chest Pain Type
- Resting Blood Pressure
- Serum Cholesterol
- Fasting Blood Sugar
- Resting ECG
- Maximum Heart Rate (Thalach)
- Exercise-Induced Angina
- ST Depression (Oldpeak)
- ST Segment Slope
All features are consistent across datasets and clinically relevant.
EDA is performed entirely inside model.py, generating:
📊 Density plots (numerical features) 🔥 Correlation heatmap 📈 Feature distributions 🌲 Feature importance (Random Forest)
These visualizations are produced during model execution to support:
- Statistical interpretation
- IEEE paper & PPT figures
- Experimental reproducibility
Note: Correlation and EDA plots are dataset-level analyses, not model-specific.
- Logistic Regression
- K-Nearest Neighbors (KNN)
- Decision Tree
- Random Forest
Each model is evaluated using:
- Accuracy
- Precision
- Recall
- F1-score
- Confusion Matrix
- ROC Curve
✔ Combines strengths of multiple models ✔ Reduces overfitting ✔ Improves stability ✔ Produces balanced predictions
- Logistic Regression
- KNN
- Decision Tree
- Random Forest
📌 Soft Voting is used to aggregate predicted probabilities.
To address skewed class distribution:
- SMOTE (Synthetic Minority Oversampling Technique) is applied
- Balances the training data before model fitting
- Improves recall and model fairness
Class distribution after SMOTE:
0 → 406
1 → 406
| Metric | Value |
|---|---|
| Accuracy | ~88–89% |
| Precision | Balanced |
| Recall | Balanced |
| F1-score | Stable |
| ROC-AUC | High (~0.94) |
✔ Confusion Matrix ✔ ROC Curve ✔ Classification Report
The trained hybrid model is deployed using FastAPI for real-time inference and backend API handling.
Step-by-step clinical input form served via Jinja2 templates
Server-side input validation using FastAPI form handling
Automatic categorical encoding aligned with saved feature structure
Feature scaling using persisted StandardScaler
Risk classification with probability score returned in structured format
Clean UI with visual indicators and response rendering
model.py → Model training, EDA, evaluation, artifact saving
app.py → FastAPI-based prediction endpoints and inference logic
static/ & templates/ → Frontend assets and presentation layer
For higher-risk predictions, the application dynamically provides a dietary recommendation link to support preventive cardiac care and lifestyle awareness, demonstrating practical decision-support integration.
Monitoring-And-Maintaining-Cardiac-Health-using-Machine-Learning-Model/
│
├── model.py # Training, EDA, evaluation, saving models
├── app.py # FastAPI application
├── heart_1.csv # Baseline dataset
├── requirements.txt # Dependencies
├── README.md # Project documentation
│
├── static/
│ ├── model/
│ │ ├── model.sav # Hybrid Voting Classifier
│ │ ├── scaler.pkl # StandardScaler
│ │ └── features.pkl # Feature order reference
│ ├── style/
│ └── script/
│
├── templates/
│ ├── home.html
│ ├── heart_disease.html
│ ├── result.html
│ ├── about.html
│ └── contact.html
All dependencies are listed in requirements.txt.
Key libraries:
- Python 3.10
- NumPy
- Pandas
- Matplotlib
- Seaborn
- Scikit-learn
- Imbalanced-learn
- fastapi
- uvicorn
- python-multipart
- jinja2
Install using:
pip install -r requirements.txtpython model.py✔ Performs EDA ✔ Trains individual & hybrid models ✔ Displays plots and metrics ✔ Saves model artifacts
python app.pyOpen in browser:
http://127.0.0.1:5000/
This project is aligned with our peer-reviewed research published on IEEE Xplore.
🔗 Monitoring and Maintaining Cardiac Health Using Machine Learning Models https://ieeexplore.ieee.org/document/11081197
Publisher: IEEE Platform: IEEE Xplore Digital Library
Focus Areas:
- Hybrid Machine Learning models
- Ensemble / Voting Classifier approach
- Comparative ML evaluation
- Practical deployment considerations
Akash Akuthota Computer Science Graduate
This project demonstrates the real-world application of ensemble machine learning techniques for healthcare risk prediction and decision support.