File size: 3,308 Bytes
473cc44
 
 
 
 
 
 
 
655cae9
 
 
19bbdf3
47faf49
19bbdf3
47faf49
 
 
19bbdf3
 
 
 
 
 
47faf49
 
 
 
 
 
19bbdf3
47faf49
 
 
 
 
19bbdf3
 
 
 
 
 
47faf49
 
 
19bbdf3
 
 
 
47faf49
 
 
 
 
 
 
 
 
 
19bbdf3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47faf49
19bbdf3
 
 
 
 
 
 
 
 
47faf49
 
 
19bbdf3
47faf49
 
 
19bbdf3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
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
```bash
git clone <repository-url>
cd AIO2025M03_HEART_DISEASE_PREDICTION
pip install -r requirements.txt
python app.py
```

### Usage
1. Ensure `data/cleveland.csv` exists (included in this repo)
2. Launch the app: `python app.py`
3. Review the About card and disclaimer at the top
4. Inspect data preview and validation metrics (trained at startup, 80/20)
5. Enter patient features or pick an example, then click Predict
6. 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:

```python
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:

```python
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