# nicolam99/icon5_23-24 architecture

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

- Interactive diagram: https://gitdiagram.com/nicolam99/icon5_23-24
- Repository: https://github.com/nicolam99/icon5_23-24

## Overview

##### Project Type and Purpose
- This is a data‐science/ML analysis pipeline centered on predicting heart disease risk.
- The primary deliverable is a Jupyter notebook (`HeartDiseaseAnalysis.ipynb`) that executes a sequence of data ingestion, preprocessing, feature engineering, model training, clustering, Bayesian inference, and result reporting steps.

##### File Structure Analysis
- Top level:
- `HeartDiseaseAnalysis.ipynb` – core notebook orchestrating the entire workflow.
- `data/processed_cleveland.data` – cleaned dataset used throughout.
- `img/` – figures referenced in documentation and notebook.
- `Documentazione.pdf` & `documentazione.md` – narrative write-ups, architecture or methodology descriptions.
- `requirements.txt` – Python dependencies.
- No separate “src” or “module” directories; code lives in the notebook.

##### Key Insights from README
- Phases: data preprocessing, feature engineering, class-imbalance handling (SMOTE), supervised classification (RandomForest, XGBoost, etc.), clustering (K-means, DBSCAN), ensemble voting, Bayesian network via pgmpy, and final evaluation.
- Tech stack: Python 3.x, Pandas, scikit-learn, XGBoost, imbalanced-learn, Matplotlib/Seaborn, pgmpy.

a. Main Components
1. External Data Source (UCI Cleveland dataset)
2. Data Ingestion & Preprocessing
3. Feature Engineering
4. Class-Imbalance Handler (SMOTE)
5. Model Training & Selection
– Classification (RandomForest, k-NN, XGBoost, DecisionTree, NaiveBayes)
– Ensemble Voting Classifier
6. Clustering Analysis (K-means, DBSCAN)
7. Bayesian Network Module (pgmpy)
8. Evaluation & Reporting (metrics, plots, documentation outputs)
9. Artifact Store (processed data, model files, charts in `img/`)
10. Notebook Execution Environment (Python kernel + dependencies)

b. Relationships & Data Flow
- Preprocessing → Feature Engineering → SMOTE → feeds into both Classification and Clustering modules.
- Classification results + Clustering outputs → Ensemble Voting → Evaluation.
- Probability tables & learned graph from Bayesian Network ← input from Feature Engineering.
- All modules output artifacts (charts, metrics) stored in `img/` and captured in the notebook.
- The notebook orchestrates all of these sequentially.

c. Architectural Patterns & Principles
- Pipeline pattern: each step transforms data and forwards to the next.
- Reproducibility: `requirements.txt` locks environment; notebook stores versioned code and outputs.
- Separation of concerns: data cleaning, feature creation, model training, and inference are distinct phases.

d. Technologies & Frameworks
- Python 3.x runtime (container or virtualenv)
- Pandas for tabular data operations
- scikit-learn for preprocessing, clustering, classification, and pipeline utilities
- imbalanced-learn (SMOTE) for class balancing
- XGBoost for gradient boosting
- pgmpy for Bayesian network construction and inference
- Matplotlib/Seaborn for visualizations
- Jupyter Notebook as orchestration layer

##### Detailing Essential Architectural Elements
- Bi-directional interactions only if there is feedback (e.g., hyperparameter tuning loops).
- Artifacts writing (plots, CSVs) explicitly.
- External calls (e.g., fetching data from UCI).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    ExtData["External Data Source<br/>(UCI Cleveland)"]:::external
    Notebook["Notebook Orchestrator"]:::orchestration
    Preprocessing["Data Ingestion & Preprocessing"]:::transformation
    FeatureEngineering["Feature Engineering"]:::transformation
    SMOTE["Class‐Imbalance Handler<br/>(SMOTE)"]:::transformation
    Classification["Classification Models<br/>(RandomForest, XGBoost,<br/>k-NN, DecisionTree, NaiveBayes)"]:::modeling
    Clustering["Clustering Analysis<br/>(K-means, DBSCAN)"]:::modeling
    Bayesian["Bayesian Network Module<br/>(pgmpy)"]:::modeling
    Ensemble["Ensemble Voting Classifier"]:::modeling
    Evaluation["Evaluation & Reporting<br/>(metrics, plots)"]:::orchestration
    ArtifactStore["Artifact Store<br/>(img/)"]:::storage
    Documentation["Documentation & Narrative"]:::docs
    Requirements["Dependency Spec<br/>(requirements.txt)"]:::storage

    %% Layout
    ExtData --> Preprocessing
    Preprocessing --> FeatureEngineering
    FeatureEngineering --> SMOTE
    SMOTE --> Classification
    SMOTE --> Clustering
    FeatureEngineering --> Bayesian
    Classification --> Ensemble
    Clustering --> Ensemble
    Ensemble --> Evaluation
    Bayesian --> Evaluation
    Evaluation --> ArtifactStore

    %% Control Plane
    Notebook -.-> Preprocessing
    Notebook -.-> FeatureEngineering
    Notebook -.-> SMOTE
    Notebook -.-> Classification
    Notebook -.-> Clustering
    Notebook -.-> Bayesian
    Notebook -.-> Ensemble
    Notebook -.-> Evaluation
    Requirements --> Notebook
    Notebook --> Documentation

    %% Click Events
    click Notebook "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/HeartDiseaseAnalysis.ipynb"
    click ExtData "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/data/processed_cleveland.data"
    click Preprocessing "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/HeartDiseaseAnalysis.ipynb"
    click FeatureEngineering "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/HeartDiseaseAnalysis.ipynb"
    click SMOTE "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/HeartDiseaseAnalysis.ipynb"
    click Classification "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/HeartDiseaseAnalysis.ipynb"
    click Clustering "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/HeartDiseaseAnalysis.ipynb"
    click Bayesian "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/HeartDiseaseAnalysis.ipynb"
    click Evaluation "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/HeartDiseaseAnalysis.ipynb"
    click ArtifactStore "https://github.com/nicolam99/icon5_23-24/tree/main/HeartDiseaseAnalysis/img/"
    click Documentation "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/documentazione.md"
    click Requirements "https://github.com/nicolam99/icon5_23-24/blob/main/HeartDiseaseAnalysis/requirements.txt"

    %% Styles
    classDef transformation fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef modeling fill:#FFF3E0,stroke:#E65100,color:#E65100;
    classDef storage fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32;
    classDef orchestration fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A;
    classDef external fill:#FFEBEE,stroke:#C62828,color:#C62828;
    classDef docs fill:#ECEFF1,stroke:#455A64,color:#455A64;
```
