# jdavidmb/emotionai architecture

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

- Interactive diagram: https://gitdiagram.com/jdavidmb/emotionai
- Repository: https://github.com/jdavidmb/emotionai

## Overview

##### Project Type and Purpose
- EmotionsAI is a machine-learning/deep-learning pipeline implemented entirely in Jupyter notebooks for early detection of mental-health issues via facial-expression classification.
- It covers data ingestion, preprocessing, three families of models (supervised ML, deep neural nets, unsupervised clustering), evaluation, and inference.

##### High-Level File Structure Analysis
- Carga de datos.ipynb → Data ingestion & preprocessing
- Entrenamiento_de_modelos.ipynb → Training supervised ML & deep-learning models
- NonsupervisedLearning.ipynb → Training and analysis of clustering algorithms
- Funcionamiento.ipynb → Inference and demonstration of model outputs
- README.md → Project overview, dataset link, model list, external references

##### Key Components
a. Data Source
- Kaggle FER dataset (48×48 grayscale faces)
- Storage: Local filesystem or mounted data directory
b. Data Ingestion & Preprocessing
- Notebook “Carga de datos.ipynb”
- Steps: load images → normalize pixel values → split train/test sets → possible data augmentation
c. Feature Extraction
- (If explicit) flatten images or extract handcrafted features (e.g., HOG, LBP)
d. Model Training
- Supervised ML block
- Gaussian Naive Bayes
- Decision Tree
- Random Forest
- Deep Learning block
- Custom neural network architecture (layers, activations)
- Unsupervised Learning block
- K-Means
- Agglomerative Clustering
e. Model Evaluation
- Metrics: accuracy, confusion matrix, precision/recall for each emotion class
- Visualization: charts generated in notebooks
f. Inference / Deployment (Notebook “Funcionamiento.ipynb”)
- Input: new face images or webcam snapshots
- Output: predicted emotion label, probability scores, plotted results
g. Auxiliary Components
- Jupyter environment and kernel dependencies (Python, NumPy, scikit-learn, TensorFlow/Keras, Matplotlib)
- External links for user reference (video demo, presentation)

##### Architectural Patterns and Design Principles
- Modular pipeline: each notebook corresponds to a pipeline stage
- Separation of concerns: ingestion, training (split by paradigm), evaluation, inference
- Reproducibility: fixed dataset split, notebook-driven code
- Extensibility: new algorithms can plug into the training block

##### Detailed Elements
- Component rectangles: Data Source, Preprocessor, Feature Extractor, Model Trainers (three sub-blocks), Evaluator, Inference Engine
- Notes on dataset link and environment dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Source
    DS["Kaggle FER Dataset"]:::data

    %% Ingestion & Preprocessing
    DP["Data Ingestion & Preprocessing"]:::process

    %% Model Training Subgraphs
    subgraph "Model Training" 
        direction TB
        subgraph "Supervised ML" 
            direction TB
            GNB["Gaussian Naive Bayes"]:::model
            DT["Decision Tree"]:::model
            RF["Random Forest"]:::model
        end
        subgraph "Deep Learning" 
            direction TB
            DNN["Custom Neural Network"]:::model
        end
        subgraph "Unsupervised Clustering"
            direction TB
            KM["K-Means"]:::model
            AG["Agglomerative Clustering"]:::model
        end
    end

    %% Evaluation & Inference
    EV["Model Evaluation"]:::eval
    IF["Inference & Demonstration"]:::eval

    %% Jupyter Environment
    JE["Jupyter Notebook Environment"]:::aux

    %% Pipeline Arrows
    DS --> DP
    DP --> GNB
    DP --> DNN
    DP --> KM
    GNB --> EV
    DT --> EV
    RF --> EV
    DNN --> EV
    KM --> EV
    AG --> EV
    EV --> IF

    %% Orchestration Dashed Arrows
    JE -.-> DP
    JE -.-> GNB
    JE -.-> DT
    JE -.-> RF
    JE -.-> DNN
    JE -.-> KM
    JE -.-> AG
    JE -.-> EV
    JE -.-> IF

    %% Legend
    subgraph "Legend"
        direction LR
        D1["Data"]:::data
        P1["Processing"]:::process
        M1["Models"]:::model
        E1["Evaluation/Inference"]:::eval
        A1["Auxiliary"]:::aux
    end

    %% Click Events
    click DP "https://github.com/jdavidmb/emotionai/blob/main/Carga de datos.ipynb"
    click GNB "https://github.com/jdavidmb/emotionai/blob/main/Entrenamiento_de_modelos.ipynb"
    click DT "https://github.com/jdavidmb/emotionai/blob/main/Entrenamiento_de_modelos.ipynb"
    click RF "https://github.com/jdavidmb/emotionai/blob/main/Entrenamiento_de_modelos.ipynb"
    click DNN "https://github.com/jdavidmb/emotionai/blob/main/Entrenamiento_de_modelos.ipynb"
    click KM "https://github.com/jdavidmb/emotionai/blob/main/NonsupervisedLearning.ipynb"
    click AG "https://github.com/jdavidmb/emotionai/blob/main/NonsupervisedLearning.ipynb"
    click IF "https://github.com/jdavidmb/emotionai/blob/main/Funcionamiento.ipynb"
    click JE "https://github.com/jdavidmb/emotionai/blob/main/README.md"

    %% Styles
    classDef data fill:#BFDBFE,stroke:#1E3A8A,color:#1E3A8A;
    classDef process fill:#D1FAE5,stroke:#047857,color:#047857;
    classDef model fill:#FED7AA,stroke:#C2410C,color:#C2410C;
    classDef eval fill:#E9D5FF,stroke:#6B21A8,color:#6B21A8;
    classDef aux fill:#F3F4F6,stroke:#374151,color:#374151;
```
