A newer version of the Gradio SDK is available:
6.1.0
metadata
title: AIO2025M03 Heart Disease Diagnosis
emoji: π«
colorFrom: blue
colorTo: red
sdk: gradio
sdk_version: 5.38.2
app_file: app.py
pinned: false
π« Cleveland Heart Disease Diagnosis (Ensemble Demo)
An interactive demo that predicts heart disease risk from patient features using an ensemble of ML models trained on the Cleveland dataset.
β¨ Features
- π§© Ensemble models: Decision Tree, k-NN, and Naive Bayes with soft voting
- π Validation metrics: ROC-AUC, Accuracy, Precision, Recall, F1 (80/20 stratified split)
- π§ͺ Patient inputs: 13 clinical features with sensible defaults and example selector
- π Results visualization: Color/emoji-coded prediction confidence bar chart per model
- βΉοΈ Clear context: Styled About card and fixed disclaimer (educational use only)
- π¨ Theming: VLAI template with configurable colors, fonts (Inter), header/footer
π Quick Start
Local Installation
git clone <repository-url>
cd AIO2025M03_HEART_DISEASE_PREDICTION
pip install -r requirements.txt
python app.py
Usage
- Ensure
data/cleveland.csvexists (included in this repo) - Launch the app:
python app.py - Review the About card and disclaimer at the top
- Inspect data preview and validation metrics (trained at startup, 80/20)
- Enter patient features or pick an example, then click Predict
- Read individual model results and the predictions overview chart
π§ Technical Highlights
- Preprocessing: Numeric median imputation; categorical most-frequent + one-hot
- Pipelines: Shared preprocessor wrapped with each estimator; ensemble via
VotingClassifier - Evaluation: Stratified train/validation split, with ROC-AUC and common classification metrics
- Visualization: Plotly bar chart; Gradio Blocks UI using VLAI template
π Requirements
- Python 3.8+
- Gradio 5.38+
- Scikit-learn
- Pandas
- NumPy
- Plotly
π¨ Theming & Branding
The UI is powered by vlai_template.py and can be customized programmatically:
import vlai_template as vt
vt.configure(
project_name="Heart Disease Diagnosis Project",
year="2025",
module="03",
description=(
"Predict heart disease risk from patient data with ML models "
"trained on the Cleveland dataset."
),
colors={
"primary": "#0F6CBD",
"accent": "#C4314B",
"bg1": "#F0F7FF",
"bg2": "#E8F0FA",
"bg3": "#DDE7F8",
},
font_family=(
"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, "
"'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif"
),
meta_items=[
("Dataset", "Cleveland Heart Disease"),
("Models", "Decision Tree, k-NN, Naive Bayes"),
("Ensemble", "Soft Voting"),
],
)
You can also inject the info and disclaimer blocks:
gr.HTML(vt.render_info_card(icon="π«", title="About this demo"))
gr.HTML(vt.render_disclaimer(
text=(
"This interactive heart disease prediction demo is provided strictly "
"for educational purposes and is not intended for clinical use."
)
))
π License
Educational use for AIO2025 course materials. This demo is not medical advice.
Live Demo: coming soon