Skip to content

Commit 93b1a30

Browse files
authored
Update README.md
1 parent 7889225 commit 93b1a30

1 file changed

Lines changed: 302 additions & 1 deletion

File tree

  • Heart Disease Prediction [END 2 END]
Lines changed: 302 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,302 @@
1-
Look for Deployed Project At ![https://github.com/shsarv/Cardio-Monitor](https://github.com/shsarv/Cardio-Monitor)
1+
- Look for final Project At **![https://github.com/shsarv/Cardio-Monitor](https://github.com/shsarv/Cardio-Monitor)**
2+
3+
<div align="center">
4+
5+
# 🫀 Cardio Monitor — Heart Disease Prediction Web App
6+
7+
[![Python](https://img.shields.io/badge/Python-3.7+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/)
8+
[![Flask](https://img.shields.io/badge/Flask-Web%20App-000000?style=for-the-badge&logo=flask&logoColor=white)](https://flask.palletsprojects.com/)
9+
[![MongoDB](https://img.shields.io/badge/MongoDB-Database-47A248?style=for-the-badge&logo=mongodb&logoColor=white)](https://www.mongodb.com/)
10+
[![scikit-learn](https://img.shields.io/badge/scikit--learn-F7931E?style=for-the-badge&logo=scikit-learn&logoColor=white)](https://scikit-learn.org/)
11+
[![Accuracy](https://img.shields.io/badge/Accuracy-92%25-brightgreen?style=for-the-badge)]()
12+
[![License](https://img.shields.io/badge/License-MIT-1abc9c?style=for-the-badge)](LICENSE)
13+
14+
> **Cardio Monitor** is a full-stack web application that predicts whether a patient is at risk of developing **heart disease** using a machine learning model with **92% accuracy** — built with Flask, MongoDB, and scikit-learn. Course project for **Big Data Analytics (BCSE0158)**.
15+
16+
[![Stars](https://img.shields.io/github/stars/shsarv/Cardio-Monitor?style=social)](https://github.com/shsarv/Cardio-Monitor/stargazers)
17+
[![Forks](https://img.shields.io/github/forks/shsarv/Cardio-Monitor?style=social)](https://github.com/shsarv/Cardio-Monitor/forks)
18+
19+
[🔗 Core ML Project](https://github.com/shsarv/Heart-Disease-Prediction) &nbsp;·&nbsp; [🐛 Report Bug](https://github.com/shsarv/Cardio-Monitor/issues) &nbsp;·&nbsp; [✨ Request Feature](https://github.com/shsarv/Cardio-Monitor/issues)
20+
21+
</div>
22+
23+
---
24+
25+
## ⚠️ Medical Disclaimer
26+
27+
> **This application is for educational and research purposes only.** It does not constitute medical advice. Always consult a qualified cardiologist or medical professional for clinical decisions.
28+
29+
---
30+
31+
## 📌 Table of Contents
32+
33+
- [About the Project](#-about-the-project)
34+
- [How It Works](#-how-it-works)
35+
- [Dataset & Features](#-dataset--features)
36+
- [Model & Performance](#-model--performance)
37+
- [Architecture](#-architecture)
38+
- [Project Structure](#-project-structure)
39+
- [Getting Started](#-getting-started)
40+
- [Future Roadmap](#-future-roadmap)
41+
- [Tech Stack](#-tech-stack)
42+
- [References](#-references)
43+
44+
---
45+
46+
## 🔬 About the Project
47+
48+
Heart disease is the leading cause of death globally. Early detection through continuous monitoring can significantly reduce mortality rates. **Cardio Monitor** combines:
49+
50+
- A **machine learning classifier** (92% accuracy) trained on the Cleveland Heart Disease dataset
51+
- A **Flask web app** for real-time patient input and prediction
52+
- A **MongoDB** backend for storing patient records and prediction history
53+
- A **visualization module** for EDA and model insights
54+
- A roadmap toward **Apache Spark Streaming** for large-scale real-time data processing
55+
56+
The core ML research and model building is documented in the companion repository: [shsarv/Heart-Disease-Prediction](https://github.com/shsarv/Heart-Disease-Prediction).
57+
58+
---
59+
60+
## ⚙️ How It Works
61+
62+
```
63+
Patient Inputs Clinical Data via Web Form
64+
65+
66+
Flask (app.py)
67+
routes request to
68+
69+
70+
prediction.py
71+
Loads Heart_model1.pkl
72+
Runs model.predict()
73+
74+
┌──────┴──────┐
75+
▼ ▼
76+
At Risk ❤️‍🩹 Not at Risk ✅
77+
78+
79+
Result displayed on web page
80+
Record saved to MongoDB (database.py)
81+
```
82+
83+
---
84+
85+
## 📊 Dataset & Features
86+
87+
| Property | Details |
88+
|----------|---------|
89+
| **File** | `heart.csv` |
90+
| **Source** | Cleveland Heart Disease Dataset (UCI ML Repository) |
91+
| **Samples** | 303 patient records |
92+
| **Task** | Binary classification — Heart Disease (1) / No Heart Disease (0) |
93+
94+
### Input Features
95+
96+
| Feature | Description | Range |
97+
|---------|-------------|-------|
98+
| `age` | Age of patient | Years |
99+
| `sex` | Sex | 0 = Female, 1 = Male |
100+
| `cp` | Chest pain type | 0–3 |
101+
| `trestbps` | Resting blood pressure | mm Hg |
102+
| `chol` | Serum cholesterol | mg/dl |
103+
| `fbs` | Fasting blood sugar > 120 mg/dl | 0 / 1 |
104+
| `restecg` | Resting ECG results | 0–2 |
105+
| `thalach` | Maximum heart rate achieved | bpm |
106+
| `exang` | Exercise induced angina | 0 / 1 |
107+
| `oldpeak` | ST depression induced by exercise | Float |
108+
| `slope` | Slope of peak exercise ST segment | 0–2 |
109+
| `ca` | Number of major vessels coloured by fluoroscopy | 0–3 |
110+
| `thal` | Thalassemia | 0–3 |
111+
| `target`| **Heart disease present** | 0 / 1 |
112+
113+
---
114+
115+
## 🤖 Model & Performance
116+
117+
| Metric | Value |
118+
|--------|:-----:|
119+
| **Accuracy** | **92%** |
120+
| **Saved Model** | `Heart_model1.pkl` / `heartmodel.pkl` |
121+
| **Algorithm** | scikit-learn classifier (see core project) |
122+
| **Library** | scikit-learn + mlxtend |
123+
124+
> Two model files are present in the repo: `Heart_model1.pkl` (primary, used by `prediction.py`) and `heartmodel.pkl` (earlier iteration). Both are serialized with `pickle`.
125+
126+
> For full model building details — EDA, feature selection, algorithm comparison, and evaluation — see the core project: [shsarv/Heart-Disease-Prediction](https://github.com/shsarv/Heart-Disease-Prediction).
127+
128+
---
129+
130+
## 🏗️ Architecture
131+
132+
```
133+
┌─────────────────────────────────────────────┐
134+
│ Flask Application │
135+
│ (app.py) │
136+
│ │
137+
│ ┌──────────┐ ┌────────────┐ ┌─────────┐ │
138+
│ │templates/│ │prediction │ │database │ │
139+
│ │ HTML │ │ .py │ │ .py │ │
140+
│ │ pages │ │ ML model │ │ MongoDB │ │
141+
│ └──────────┘ └────────────┘ └─────────┘ │
142+
│ │
143+
│ ┌──────────────────────────────────────┐ │
144+
│ │ static/ │ │
145+
│ │ CSS · JS · images │ │
146+
│ └──────────────────────────────────────┘ │
147+
└─────────────────────────────────────────────┘
148+
│ │
149+
▼ ▼
150+
Heart_model1.pkl MongoDB Atlas
151+
(scikit-learn) (patient records
152+
+ predictions)
153+
```
154+
155+
---
156+
157+
## 📁 Project Structure
158+
159+
```
160+
Cardio-Monitor/
161+
162+
├── 📂 heart disease prediction/ # Jupyter notebooks — EDA & model training
163+
├── 📂 static/ # CSS, JS, images
164+
├── 📂 templates/ # Jinja2 HTML templates (input form, result pages)
165+
├── 📂 __pycache__/
166+
167+
├── app.py # Flask entry point — routes and app config
168+
├── prediction.py # Loads Heart_model1.pkl, runs inference
169+
├── modelbuild.py # Model training and serialization script
170+
├── database.py # MongoDB connection and CRUD operations
171+
├── visualization.py # EDA and data visualization utilities
172+
173+
├── Heart_model1.pkl # Primary trained model (pickle)
174+
├── heartmodel.pkl # Alternate model iteration (pickle)
175+
├── heart.csv # Cleveland Heart Disease dataset
176+
├── Input Data.png # Screenshot of the web app input form
177+
178+
├── Procfile # Heroku deployment config
179+
├── requirements.txt # Python dependencies
180+
├── .gitignore
181+
└── README.md
182+
```
183+
184+
---
185+
186+
## 🚀 Getting Started
187+
188+
### Prerequisites
189+
190+
- Python 3.7+
191+
- MongoDB (local or [MongoDB Atlas](https://www.mongodb.com/cloud/atlas))
192+
193+
### 1. Clone the repository
194+
195+
```bash
196+
git clone https://github.com/shsarv/Cardio-Monitor.git
197+
cd Cardio-Monitor
198+
```
199+
200+
### 2. Set up environment
201+
202+
```bash
203+
python -m venv venv
204+
source venv/bin/activate # Linux / macOS
205+
venv\Scripts\activate # Windows
206+
207+
pip install -r requirements.txt
208+
```
209+
210+
### 3. Configure MongoDB
211+
212+
In `database.py`, update your MongoDB connection string:
213+
214+
```python
215+
# Local MongoDB
216+
client = pymongo.MongoClient("mongodb://localhost:27017/")
217+
218+
# MongoDB Atlas (cloud)
219+
client = pymongo.MongoClient("mongodb+srv://<user>:<password>@cluster.mongodb.net/")
220+
```
221+
222+
### 4. Run the app
223+
224+
```bash
225+
python app.py
226+
```
227+
228+
Navigate to → **http://127.0.0.1:5000**
229+
230+
### 5. Deploy to Heroku
231+
232+
```bash
233+
heroku login
234+
heroku create cardio-monitor-app
235+
git push heroku main
236+
heroku open
237+
```
238+
239+
> The `Procfile` already contains: `web: gunicorn app:app`
240+
241+
---
242+
243+
## 🗺️ Future Roadmap
244+
245+
| Feature | Status |
246+
|---------|:------:|
247+
| Flask web app with MongoDB | ✅ Done |
248+
| 92% accuracy ML model | ✅ Done |
249+
| Heroku deployment | ✅ Done |
250+
| **Apache Spark Streaming** — real-time patient data ingestion | 🔜 Planned |
251+
| **PySpark MLlib** — large-scale distributed model training | 🔜 Planned |
252+
| **Deep Learning model** (Keras/TensorFlow) | 🔜 Planned |
253+
| Live demo deployment | 🔜 Planned |
254+
255+
---
256+
257+
## 🛠️ Tech Stack
258+
259+
**Current:**
260+
261+
| Layer | Technology |
262+
|-------|-----------|
263+
| Language | Python 3.7+ |
264+
| Web Framework | Flask |
265+
| ML Library | scikit-learn, mlxtend |
266+
| Database | MongoDB (PyMongo) |
267+
| Model Serialization | Pickle |
268+
| Frontend | HTML5, CSS3, Bootstrap |
269+
| Deployment | Heroku (Procfile + gunicorn) |
270+
| Notebook | Jupyter |
271+
272+
**Planned (Future):**
273+
274+
| Layer | Technology |
275+
|-------|-----------|
276+
| Streaming | Apache Spark Streaming |
277+
| Distributed ML | PySpark MLlib |
278+
| Deep Learning | Keras / TensorFlow (DeepL) |
279+
| Database (scale) | MongoDB Atlas |
280+
281+
---
282+
283+
## 📚 References
284+
285+
- [Cleveland Heart Disease Dataset — UCI ML Repository](https://archive.ics.uci.edu/ml/datasets/Heart+Disease)
286+
- [Core ML Project — shsarv/Heart-Disease-Prediction](https://github.com/shsarv/Heart-Disease-Prediction)
287+
- [Flask Documentation](https://flask.palletsprojects.com/)
288+
- [PyMongo Documentation](https://pymongo.readthedocs.io/)
289+
- [mlxtend Documentation](https://rasbt.github.io/mlxtend/)
290+
- [Apache Spark Streaming](https://spark.apache.org/streaming/)
291+
292+
---
293+
294+
<div align="center">
295+
296+
**Created by [Sarvesh Kumar Sharma](https://github.com/shsarv)**
297+
298+
Course Project — Big Data Analytics (BCSE0158)
299+
300+
⭐ Star this repo if you found it helpful!
301+
302+
</div>

0 commit comments

Comments
 (0)