# jammulavarun/heart_disease_prediction architecture

> Architecture diagram of the GitHub repository jammulavarun/heart_disease_prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jammulavarun/heart_disease_prediction
- Repository: https://github.com/jammulavarun/heart_disease_prediction

## Overview

##### Project type and purpose
- This is a data-science / machine-learning project whose goal is to train and evaluate a logistic regression model to predict whether a patient has heart disease, based on the features in heart.csv. There is no existing frontend or backend service—just a Jupyter notebook, raw data, and a README.

##### File structure
- Top level:
- Heart_Disease_Predictoin.ipynb – the interactive notebook combining data loading, preprocessing, training, evaluation, and visualization.
- heart.csv – the source dataset.
- README.md – project description and data schema.
- No separate src/, tests/, or deployment artifacts, so all logic lives in the notebook.

##### README for additional insights
- Confirms model is logistic regression for binary classification.
- Enumerates each feature and its meaning.
- No mention of external services, data stores beyond the CSV, or deployment targets.

a. Data Ingestion
- Component: “CSV Data Source”
- Reads heart.csv
b. Data Preprocessing
- Component: “Preprocessing”
- Operations: missing-value handling (if any), encoding categorical features (cp, thal), scaling numeric features (trestbps, chol, etc.)
c. Model Training
- Component: “Logistic Regression Trainer”
- Input: preprocessed data
- Output: trained model artifact (e.g., pickle file)
d. Model Evaluation
- Component: “Evaluation & Metrics”
- Input: hold-out test split
- Outputs: accuracy, confusion matrix, ROC curve
e. (Optional) Model Persistence & Deployment
- Component: “Model Registry / Storage” (e.g., local disk or S3)
- Component: “Inference Service” – exposes REST API endpoint for predictions

##### Relationships & Data Flow
CSV Data Source → Preprocessing → Trainer → Model Artifact → (optional) Inference Service
Trainer → Evaluation → Metrics Dashboard
- That the notebook orchestrates these steps sequentially.

##### Architectural patterns and design principles
- Modular pipeline stages (ingest, prep, train, eval) follow best-practice ML workflow.
- Decouple preprocessing logic from model training to enable reuse.
- (If extended) Use a simple microservice to serve predictions, separate from training.

##### Technologies / Frameworks to call out
- Python / pandas for data ingestion & preprocessing
- scikit-learn’s LogisticRegression
- Jupyter Notebook as orchestration environment
- (Optional) Flask or FastAPI for serving the model
- pickle or joblib for model persistence

##### Detail level
- Every major step the notebook performs: reading the CSV; feature encoding; train/test split; model.fit; model.predict_proba; metric calculations; visualization outputs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Source
    DataSrc[(CSV Data Source)]:::data
    %% Notebook Orchestrator
    subgraph "Jupyter Notebook" 
        Preprocessing["Data Preprocessing"]:::process
        Trainer["Logistic Regression Trainer"]:::process
        Evaluation["Evaluation & Metrics"]:::eval
        ModelArtifact[(Model Artifact)]:::data
    end
    %% Deployment
    Inference["Inference Service"]:::deploy

    %% Data Flow
    DataSrc -->|reads heart.csv| Preprocessing
    Preprocessing -->|preprocessed data| Trainer
    Trainer -->|trained model| ModelArtifact
    Trainer -->|evaluate on test split| Evaluation
    ModelArtifact -->|model for inference| Inference

    %% Click Events
    click DataSrc "https://github.com/jammulavarun/heart_disease_prediction/blob/main/heart.csv"
    click Preprocessing "https://github.com/jammulavarun/heart_disease_prediction/blob/main/Heart_Disease_Predictoin.ipynb"
    click Trainer "https://github.com/jammulavarun/heart_disease_prediction/blob/main/Heart_Disease_Predictoin.ipynb"
    click Evaluation "https://github.com/jammulavarun/heart_disease_prediction/blob/main/Heart_Disease_Predictoin.ipynb"
    click ModelArtifact "https://github.com/jammulavarun/heart_disease_prediction/blob/main/Heart_Disease_Predictoin.ipynb"

    %% Styles
    classDef data fill:#cce5ff,stroke:#000,color:#000;
    classDef process fill:#d4edda,stroke:#000,color:#000;
    classDef eval fill:#fff3cd,stroke:#000,color:#000;
    classDef deploy fill:#e2e3e5,stroke:#000,color:#000;
    classDef notebook stroke:#999,stroke-dasharray: 5 5;
```
