# tianxiangzhao/graphsmote architecture

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

- Interactive diagram: https://gitdiagram.com/tianxiangzhao/graphsmote
- Repository: https://github.com/tianxiangzhao/graphsmote

## Overview

##### Project Type and Purpose
- This is a machine learning research project that implements GraphSMOTE. Its purpose is to address imbalanced classification in graph data, where nodes may belong to minority classes.
- The README explains that it supports experiments on various datasets (BlogCatalog, Cora, and Twitter) and provides multiple baseline models (e.g., vanilla, upsampling, reweighting, and embed-SMOTE) alongside two network architectures (GraphSage and GCN).

##### Analyzing the File Structure
- Top-level items include:
- README.md – documentation.
- A “checkpoint” directory – holds model checkpoints for different datasets (BlogCatalog and Cora), indicating storage of trained models.
- A “data” directory – expected location for dataset files. It includes placeholder folders for datasets and specific CSV files (e.g., twitter_fake_ids.csv).
- Several Python scripts:
◦ main.py – likely the entry point for training and evaluation.
◦ models.py – contains definitions of the graph neural network models and potentially different architectural choices.
◦ utils.py – contains helper functions including argument parsing (get_parser()) and possibly configuration management.
◦ data_load.py – dedicated to loading the external datasets, possibly including pre-processing and conversion steps.
- This indicates a modular design where data ingestion, model definition, execution logic, and utility functions are separated into distinct components.

##### Elements to Be Included
- Incorporate labels for different baseline configurations and indicate alternative paths for pretraining vs. fine-tuning.
- If possible, distinguish experimental settings (like oversampling, reweighting, etc.) as sub-options within the main training flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Components
    subgraph "Data Components"
        DS["Data Sources (BlogCatalog, Cora, Twitter)"]:::dataStyle
        DE["Deepwalk (External)"]:::externalStyle
    end

    %% Preprocessing
    subgraph "Preprocessing"
        B["Data Loader (data_load.py)"]:::moduleStyle
    end

    %% Training Pipeline
    subgraph "Training Pipeline"
        TP["Training Pipeline (main.py)"]:::moduleStyle
        MA["Model Architectures (models.py: GraphSage, GCN)"]:::moduleStyle
        UT["Utilities/Configuration (utils.py)"]:::utilityStyle
    end

    %% Persistent Storage
    subgraph "Persistent Storage"
        CH["Checkpoint Management"]:::storageStyle
        CH1["BlogCatalog Checkpoint"]:::storageStyle
        CH2["Cora Checkpoint"]:::storageStyle
    end

    %% Connections
    DS -->|"load"| B
    B -->|"prepare_data"| TP
    DS -->|"embedding"| DE
    DE -->|"embedding_result"| TP
    TP -->|"uses"| MA
    TP -->|"configures"| UT
    TP -->|"save/load"| CH
    CH -->|"stores"| CH1
    CH -->|"stores"| CH2

    %% Click Events
    click DS "https://github.com/tianxiangzhao/graphsmote/tree/main/data/Put_dataset_folder_here"
    click B "https://github.com/tianxiangzhao/graphsmote/blob/main/data_load.py"
    click TP "https://github.com/tianxiangzhao/graphsmote/blob/main/main.py"
    click MA "https://github.com/tianxiangzhao/graphsmote/blob/main/models.py"
    click UT "https://github.com/tianxiangzhao/graphsmote/blob/main/utils.py"
    click CH "https://github.com/tianxiangzhao/graphsmote/tree/main/checkpoint"
    click CH1 "https://github.com/tianxiangzhao/graphsmote/tree/main/checkpoint/BlogCatalog"
    click CH2 "https://github.com/tianxiangzhao/graphsmote/tree/main/checkpoint/cora"

    %% Styles
    classDef dataStyle fill:#a8d5e2,stroke:#086375,stroke-width:2px;
    classDef moduleStyle fill:#d4efdf,stroke:#27ae60,stroke-width:2px;
    classDef utilityStyle fill:#fdebd0,stroke:#d35400,stroke-width:2px;
    classDef storageStyle fill:#e8daef,stroke:#8e44ad,stroke-width:2px;
    classDef externalStyle fill:#f9e79f,stroke:#d4ac0d,stroke-width:2px;
```
