# saksham2311/mental-health-prediction-machinelearning architecture

> Architecture diagram of the GitHub repository saksham2311/mental-health-prediction-machinelearning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saksham2311/mental-health-prediction-machinelearning
- Repository: https://github.com/saksham2311/mental-health-prediction-machinelearning

## Overview

##### Project type and purpose
- This is a standalone data-science/machine-learning project organized around a Jupyter notebook (`MentalHealthPrediction.ipynb`).
- Purpose: ingest a tech-workplace mental-health survey dataset, perform feature selection (ExtraTreesClassifier), train three models (LogisticRegression, KNeighborsClassifier, DecisionTreeClassifier), compare their accuracy, and output results to `results.csv`.

##### File structure
- Top-level files only—no subdirectories.
– `survey.csv`: raw input data.
– `MentalHealthPrediction.ipynb`: contains all data-loading, preprocessing, feature-extraction, model training, evaluation, and export code.
– `results.csv`: final performance metrics.
– `README.md` and `LICENSE`.
- No separate scripts, services, or deployment artifacts—this is a single-notebook ETL + ML pipeline.

##### Extract architecture insights from the README
- Dataset from Kaggle 2014 tech-workplace mental health survey.
- Feature importance via ExtraTreesClassifier.
- Three supervised learning algorithms used with accuracy comparison.

##### Main components
a. Data Ingestion Layer
– Component: CSV Data Source (`survey.csv`).
– Function: load raw survey records into memory.
b. Data Preprocessing & Feature Extraction
– Component: Notebook cell sequence or “Data Prep Module.”
– Sub-components:
- Cleaning (null handling, encoding).
- Feature selection (ExtraTreesClassifier).
c. Model Training
– Component: “Training Module” within the notebook.
– Sub-components for each algorithm:
- Logistic Regression
- KNeighborsClassifier
- DecisionTreeClassifier
d. Model Evaluation & Comparison
– Component: “Evaluation Module.”
– Generates accuracy metrics, confusion matrices.
e. Results Export
– Component: CSV Exporter
– Writes `results.csv` with model performance.

##### Architectural patterns & design principles
- Linear ETL + ML pipeline: data ingestion → transform → train → evaluate → export.
- Modularity: separate logical stages inside the notebook.
- Reusability points: you could extract code cells into functions or scripts for production.

##### Technologies and libraries
- Python & Jupyter Notebook (runtime environment).
- pandas / numpy (data handling).
- scikit-learn: ExtraTreesClassifier, LogisticRegression, KNeighborsClassifier, DecisionTreeClassifier.
- CSV I/O modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Source
    survey_csv[(survey.csv)]:::data

    %% Notebook Orchestrator
    subgraph "Notebook Orchestrator"
        direction TB
        subgraph "Data Preprocessing & Feature Extraction"
            direction TB
            cleaning["Cleaning & Encoding"]:::preprocessing
            featureSelection["Feature Selection\n(ExtraTreesClassifier)"]:::preprocessing
        end

        subgraph "Model Training"
            direction TB
            logistic["Logistic Regression"]:::training
            knn["KNeighborsClassifier"]:::training
            decisionTree["DecisionTreeClassifier"]:::training
        end

        evaluation["Evaluation & Comparison"]:::evaluation
        export["Results Export\n(writes results.csv)"]:::evaluation
    end

    %% User/Report
    user["User / Report"]

    %% Data Flow
    survey_csv -->|"load raw data"| cleaning
    cleaning -->|"cleaned data"| featureSelection
    featureSelection -->|"feature set"| logistic
    featureSelection -->|"feature set"| knn
    featureSelection -->|"feature set"| decisionTree
    logistic -->|"trained model"| evaluation
    knn -->|"trained model"| evaluation
    decisionTree -->|"trained model"| evaluation
    evaluation -->|"metrics"| export
    export -->|"output report"| user

    %% Click Events
    click survey_csv "https://github.com/saksham2311/mental-health-prediction-machinelearning/blob/main/survey.csv"
    click cleaning "https://github.com/saksham2311/mental-health-prediction-machinelearning/blob/main/MentalHealthPrediction.ipynb"
    click featureSelection "https://github.com/saksham2311/mental-health-prediction-machinelearning/blob/main/MentalHealthPrediction.ipynb"
    click logistic "https://github.com/saksham2311/mental-health-prediction-machinelearning/blob/main/MentalHealthPrediction.ipynb"
    click knn "https://github.com/saksham2311/mental-health-prediction-machinelearning/blob/main/MentalHealthPrediction.ipynb"
    click decisionTree "https://github.com/saksham2311/mental-health-prediction-machinelearning/blob/main/MentalHealthPrediction.ipynb"
    click evaluation "https://github.com/saksham2311/mental-health-prediction-machinelearning/blob/main/MentalHealthPrediction.ipynb"
    click export "https://github.com/saksham2311/mental-health-prediction-machinelearning/blob/main/results.csv"

    %% Styles
    classDef data fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef preprocessing fill:#d4edda,stroke:#333,stroke-width:1px
    classDef training fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef evaluation fill:#e2e3ff,stroke:#333,stroke-width:1px
```
