# karlemami/deft architecture

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

- Interactive diagram: https://gitdiagram.com/karlemami/deft
- Repository: https://github.com/karlemami/deft

## Overview

##### Main Components

A. Data Processing Layer
- Data Acquisition Component (data/download_data.sh)
- Data Preprocessing Pipeline (src/preprocessing/)
- Descriptive Statistics Generator (src/descriptive_stats/)

B. Feature Engineering Layer
- Vectorization Components:
- TF-IDF Vectorizer
- Doc2Vec Vectorizer
- BERT Embeddings

C. Model Layer
- Classification Components:
- Random Forest Classifier
- Support Vector Machine
- Logistic Regression
- Perceptron
- Training Pipeline (src/classification/Trainer.py)
- Model Evaluation System

D. Results Management Layer
- Performance Metrics Storage
- Best Parameters Storage
- Results Output Generation

**[Data Input] → [Preprocessing] → [Vectorization] → [Model Training/Testing] → [Results Output]**

##### Specific Implementation Details

Top Level:
**Configuration (config.yaml) ─────┐**
- ↓
**Raw Data → Preprocessing → Vectorization → Classification → Results**
- ↓                                             ↑
- Statistics Generation ──────────────────────────────┘

Detail Level:
- ┌─── TF-IDF ───┐
**Raw Data → Preprocessing → Doc2Vec → [Model Pool] → Evaluation → Results**
- BERT ────┘    - RFC
- SVM
- LR
- Perceptron

##### Important Elements to Highlight

- Multi-language support (fr, en, it)
- Configurable pipeline components
- Multiple vectorization options
- Various classification algorithms
- Results storage structure
- Parameter optimization workflow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Processing Component]
        L2[(Data Storage)]
        L3{{Model Component}}
        L4[/API or Script/]
        L5([Configuration])
    end

    classDef storage fill:#f9f,stroke:#333
    classDef processing fill:#aef,stroke:#333
    classDef model fill:#fca,stroke:#333
    classDef api fill:#afa,stroke:#333
    classDef config fill:#ddd,stroke:#333
    classDef stats fill:#e6e6fa,stroke:#333

    Config([Configuration]):::config
    click Config "https://github.com/Karlemami/DEFT/blob/main/config.yaml"

    DataAcq[/Data Acquisition/]:::api
    click DataAcq "https://github.com/Karlemami/DEFT/blob/main/data/download_data.sh"

    Preproc[Data Preprocessing]:::processing
    click Preproc "https://github.com/Karlemami/DEFT/blob/main/src/preprocessing/DataLoader.py"

    Stats[Statistics Generator]:::stats
    click Stats "https://github.com/Karlemami/DEFT/blob/main/src/descriptive_stats/Stats.py"

    StatsStorage[(Statistics Storage)]:::storage
    click StatsStorage "https://github.com/Karlemami/DEFT/blob/main/stats/data.json"

    subgraph Vectorization
        TFIDF[TF-IDF Vectorizer]:::processing
        Doc2Vec[Doc2Vec Vectorizer]:::processing
        BERT[BERT Embeddings]:::processing
    end

    subgraph "Model Components"
        RFC{{Random Forest}}:::model
        SVM{{Support Vector Machine}}:::model
        LR{{Logistic Regression}}:::model
        Perceptron{{Perceptron}}:::model
    end

    Trainer[Training Pipeline]:::processing
    click Trainer "https://github.com/Karlemami/DEFT/blob/main/src/classification/Trainer.py"

    ClassificationFramework[Classification Framework]:::processing
    click ClassificationFramework "https://github.com/Karlemami/DEFT/blob/main/src/classification/Classifier.py"

    subgraph "Results Storage"
        BERTResults[(BERT Results)]:::storage
        click BERTResults "https://github.com/Karlemami/DEFT/tree/main/results/results_bert/"
        Doc2VecResults[(Doc2Vec Results)]:::storage
        click Doc2VecResults "https://github.com/Karlemami/DEFT/tree/main/results/results_doc2vec/"
        TFIDFResults[(TF-IDF Results)]:::storage
        click TFIDFResults "https://github.com/Karlemami/DEFT/tree/main/results/results_tfidf/"
    end

    BestParams[(Best Parameters)]:::storage
    click BestParams "https://github.com/Karlemami/DEFT/tree/main/best_params/fr/"

    Documentation[Documentation]:::processing
    click Documentation "https://github.com/Karlemami/DEFT/blob/main/doc/presentation.md"

    DataAcq --> Preproc
    Preproc --> Stats
    Stats --> StatsStorage
    
    Preproc --> TFIDF
    Preproc --> Doc2Vec
    Preproc --> BERT
    
    TFIDF --> ClassificationFramework
    Doc2Vec --> ClassificationFramework
    BERT --> ClassificationFramework
    
    ClassificationFramework --> RFC
    ClassificationFramework --> SVM
    ClassificationFramework --> LR
    ClassificationFramework --> Perceptron
    
    RFC & SVM & LR & Perceptron --> Trainer
    
    Trainer --> BERTResults
    Trainer --> Doc2VecResults
    Trainer --> TFIDFResults
    Trainer --> BestParams
    
    Config --> Preproc
    Config --> ClassificationFramework
    Config --> Trainer

    BERTResults & Doc2VecResults & TFIDFResults --> Documentation
```
