# kazabana/pr-pl architecture

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

- Interactive diagram: https://gitdiagram.com/kazabana/pr-pl
- Repository: https://github.com/kazabana/pr-pl

## Overview

##### Project type and purpose
- This is a research‐oriented machine‐learning pipeline for EEG‐based emotion recognition, not a typical web or microservices app.
- It implements the PR-PL (Prototypical Representation based Pairwise Learning) framework in PyTorch, plus a domain adversarial training module.

##### File structure
- Top-level scripts:
- data_prepare_seed.m – MATLAB script to download/prepare raw SEED/SEED-IV EEG data
- feature_wrap.m – MATLAB function to extract or wrap features from preprocessed EEG signals
- implementation_PR_PL.py – main Python pipeline that orchestrates data loading, training, evaluation
- model_PR_PL.py – PyTorch module defining the backbone network and prototypical/pairwise learning losses
- Adversarial.py – Python module implementing domain adversarial training (built on dalib)
- No nested directories; clear separation between data prep (MATLAB) and model training (Python).

##### Key insights from the README
- Dependencies: Python 3.7, PyTorch 1.3.1, CUDA 9.2, NumPy, Sci-Kit Learn, SciPy
- Workflow:
a) Run MATLAB scripts to prepare and wrap features from raw EEG
b) Configure paths in implementation_PR_PL.py
c) Launch Python training pipeline, which calls model_PR_PL.py and Adversarial.py
- Acknowledges use of dalib for adversarial components.

##### Elements
- Green for model/training modules (Python)
- Orange for external libs (dalib)

## Diagram (Mermaid)

```mermaid
flowchart TD
    RawData["Raw Data Store (.mat)"]:::db
    DataPrep["Data Preparation (.m)"]:::matlab
    FeatureExt["Feature Extraction (.m)"]:::matlab
    Preprocessed["Preprocessed Dataset"]:::db
    PyPipeline["Python Training Pipeline"]:::python
    ModelDef["Model Definition (.py)"]:::python
    AdvModule["Domain Adversarial Module (.py)"]:::python
    DALib["dalib (external library)"]:::external
    Eval["Evaluation & Metrics"]:::python
    Results["Results Output (checkpoints, logs)"]:::output

    RawData --> DataPrep
    DataPrep --> FeatureExt
    FeatureExt --> Preprocessed
    Preprocessed --> PyPipeline
    PyPipeline <--> ModelDef
    PyPipeline <--> AdvModule
    AdvModule --> DALib
    PyPipeline --> Eval
    Eval --> Results

    click DataPrep "https://github.com/kazabana/pr-pl/blob/main/data_prepare_seed.m"
    click FeatureExt "https://github.com/kazabana/pr-pl/blob/main/feature_wrap.m"
    click PyPipeline "https://github.com/kazabana/pr-pl/blob/main/implementation_PR_PL.py"
    click ModelDef "https://github.com/kazabana/pr-pl/blob/main/model_PR_PL.py"
    click AdvModule "https://github.com/kazabana/pr-pl/blob/main/Adversarial.py"

    classDef matlab fill:#e0f7fa,stroke:#006064,color:#006064;
    classDef python fill:#e8f5e9,stroke:#2e7d32,color:#2e7d32;
    classDef db fill:#fff3e0,stroke:#ef6c00,color:#e65100;
    classDef external fill:#fce4ec,stroke:#ad1457,color:#880e4f;
    classDef output fill:#ede7f6,stroke:#5e35b1,color:#4527a0;
```
