How umayashaswi/heart-disease-prediction works
Project type and purpose
• This is a lightweight full-stack web application for heart disease prediction.
• The core functionality: collect patient inputs via a web form, feed them to a pre-trained Random Forest model, and render the prediction result in the browser.
File structure
• Top-level:
• Heart_disease_prediction.ipynb – exploratory notebook (data analysis & model training).
• app.py – Flask application entry point (serves pages, handles form submissions).
• heart1.csv – raw dataset (used offline for model training).
• random_forest_model.pkl – serialized ML model.
• templates – Jinja2 HTML templates (views).
• No external microservices or databases—everything is in-process and file-based.
README
• Contains only a demonstration link, so no extra architectural guidance there.
a. Main components
1. Client (Web Browser)
2. HTTP Layer / WSGI Server (Flask)
3. View Layer (templates + static files)
4. Controller Layer (app.py routes & form handlers)
5. Model Layer (Random Forest model + data I/O)
6. Data Store (flat files: heart1.csv for notebook, random_forest_model.pkl at runtime)
b. Relationships & interactions
• User → (1) loads “home.html” or “index.html” from Flask → browser renders form.
• User submits form → HTTP POST → Flask route (“/predict”) → Controller reads form data.
• Controller loads random_forest_model.pkl into memory → passes input into ML model → gets prediction.
• Controller renders a result template (e.g., h1.html) with the prediction → sent back to browser.
• Static files/images served alongside templates for UI assets.
• Notebook (Heart_disease_prediction.ipynb) interacts offline with heart1.csv to train & export random_forest_model.pkl (not in the live request path).
c. Architectural patterns & principles
• MVC-style separation:
• Model: serialized ML object & CSV used for training.
• View: Jinja2 templates in /templates + static assets in /static.
• Controller: Flask routes in app.py.
• Single monolithic service—no external DB or third‐party APIs.
• Stateless request handling (each prediction loads the model or retains it in memory across requests).
d. Key technologies/frameworks
• Python 3 + Flask (web framework)
• Jinja2 (templating)
• scikit-learn Random Forest saved via pickle
• HTML/CSS/JavaScript (client side)
• CSV flat file for training data
Elements
• Browser → Flask App (HTTP GET/POST)
• Flask App → Templates & Static Files (serve UI)
• Flask App → Random Forest Model (load & predict)
• Notebook → CSV → Model (train & serialize)
• Frontend (blue), Backend (green), Offline Training Workflow (orange).