# harsha-chirumamilla/pscl architecture

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

- Interactive diagram: https://gitdiagram.com/harsha-chirumamilla/pscl
- Repository: https://github.com/harsha-chirumamilla/pscl

## Overview

##### Project Type and Purpose
- This is a research-oriented machine-learning pipeline for multi-label classification of protein subcellular localization using Gene Ontology (GO) term annotations.
- There is no classic “frontend/backend” service; instead, it consists of data sources, preprocessing/feature-engineering modules, model-training & evaluation notebooks, and model artifacts.

##### Main Components
a. Data Layer
- Datasets/ (raw training & test tables in CSV, parquet, gz)
- Relations/ (GO term relationship CSVs)
b. Adjacency Matrix Generation
- Utils/adj_matrix.py → produces parquet files in Adj_Matrices/
c. Feature Engineering
- Utils/Feat_generator.py → reads raw Datasets + Adj_Matrices + Relations to compute embeddings/feature vectors (Features/Actual and Features/Independent subfolders, HMM & PSSM)
- External graph embedding library: node2vec & NetworkX
d. Model Training & Evaluation
- Notebooks/ – Jupyter notebooks that load Features, train multiple classifiers (DT, KNN, RF, SVC, Keras deep nets) and compute metrics (strict/relaxed accuracy)
- Protein_Bert/ – specialized notebooks for ProtBert embedding experiments
e. Model Artifact Storage
- Models/ – saved Keras models (e.g. Ind_GO_1.keras)
f. Utilities & Metrics
- Notebooks/multiLabelMetrics.py – evaluation helper
- Notebooks/ClassLabels.py – label encoding

##### Component Interactions and Data Flow
1. Raw GO relationships (Relations/) + Datasets/ feed into adj_matrix.py → Adj_Matrices/
2. Adj_Matrices/ + Datasets/ + Relations/ → Feat_generator.py → Features/Actual & Features/Independent
3. Features → training notebooks → model artifacts saved to Models/
4. Trained models + held-out test sets → evaluation notebooks → metrics & visualizations

##### Architectural Patterns & Design Principles
- Layered pipeline: data ingestion → transformation → modeling → evaluation
- Clear separation of concerns:
- Raw data vs precomputed adjacency vs computed features
- Feature-generation code (Utils) vs experimental notebooks
- Modular, extensible: new feature types or model types can be slotted into the same pipeline

##### Key Technologies & Frameworks
- Data handling: Pandas, PyArrow
- Graph processing: NetworkX, node2vec
- ML: scikit-learn (RF, DT, KNN, SVC), TensorFlow/Keras (deep nets)
- Notebook environment: Jupyter
- File formats: CSV, Parquet, gz

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "1. Data Layer"
        Datasets[(Datasets/)]:::data
        Relations[(Relations/)]:::data
    end

    %% Preprocessing Layer
    subgraph "2. Preprocessing Layer"
        AdjScript["Utils/adj_matrix.py"]:::pre
        AdjMat[(Adj_Matrices/)]:::data
    end

    %% Feature Engineering Layer
    subgraph "3. Feature Engineering Layer"
        FeatScript["Utils/Feat_generator.py"]:::pre
        ActFeat[(Features/Actual/)]:::feature
        IndFeat[(Features/Independent/)]:::feature
    end

    %% Modeling & Experiments Layer
    subgraph "4. Modeling & Experiments"
        NB["Notebooks/"]:::modeling
        PB["Protein_Bert/"]:::modeling
    end

    %% Artifacts & Metrics Layer
    subgraph "5. Artifacts & Metrics"
        Models[(Models/)]:::artifact
        Metrics[(Metrics & Visuals)]:::artifact
        MLM["multiLabelMetrics.py"]:::artifact
        CL["ClassLabels.py"]:::artifact
        CL1["ClassLabels1.py"]:::artifact
    end

    %% Connections
    Datasets -->|CSV, Parquet| AdjScript
    Relations -->|CSV| AdjScript
    AdjScript -->|Parquet| AdjMat

    Datasets -->|Raw Tables| FeatScript
    Relations -->|GO Relations| FeatScript
    AdjMat -->|Adj Matrices| FeatScript
    FeatScript -->|Feature Vectors| ActFeat
    FeatScript -->|Feature Vectors| IndFeat

    ActFeat -->|Inputs| NB
    IndFeat -->|Inputs| NB
    ActFeat -->|Inputs| PB
    IndFeat -->|Inputs| PB

    NB -->|Saves Models| Models
    NB -->|Generates Metrics| Metrics
    PB -->|Saves Models| Models
    PB -->|Generates Metrics| Metrics

    MLM -->|Used by| NB
    CL -->|Used by| NB
    CL1 -->|Used by| PB

    %% Click Events
    click Datasets "https://github.com/harsha-chirumamilla/pscl/tree/main/Datasets/"
    click Relations "https://github.com/harsha-chirumamilla/pscl/tree/main/Relations/"
    click AdjScript "https://github.com/harsha-chirumamilla/pscl/blob/main/Utils/adj_matrix.py"
    click AdjMat "https://github.com/harsha-chirumamilla/pscl/tree/main/Adj_Matrices/"
    click FeatScript "https://github.com/harsha-chirumamilla/pscl/blob/main/Utils/Feat_generator.py"
    click ActFeat "https://github.com/harsha-chirumamilla/pscl/tree/main/Features/Actual/"
    click IndFeat "https://github.com/harsha-chirumamilla/pscl/tree/main/Features/Independent/"
    click NB "https://github.com/harsha-chirumamilla/pscl/tree/main/Notebooks/"
    click PB "https://github.com/harsha-chirumamilla/pscl/tree/main/Protein_Bert/"
    click MLM "https://github.com/harsha-chirumamilla/pscl/blob/main/Notebooks/multiLabelMetrics.py"
    click CL "https://github.com/harsha-chirumamilla/pscl/blob/main/Notebooks/ClassLabels.py"
    click CL1 "https://github.com/harsha-chirumamilla/pscl/blob/main/Protein_Bert/ClassLabels1.py"
    click Models "https://github.com/harsha-chirumamilla/pscl/tree/main/Models/"

    %% Styles
    classDef data fill:#e0f2f1,stroke:#00695c,stroke-width:2px
    classDef pre fill:#bbdefb,stroke:#0d47a1,stroke-width:2px
    classDef feature fill:#fff9c4,stroke:#f9a825,stroke-width:2px
    classDef modeling fill:#ffe0b2,stroke:#e65100,stroke-width:2px
    classDef artifact fill:#e1bee7,stroke:#6a1b9a,stroke-width:2px
```
