# ywjawmw/smgcn-torch-master architecture

> Architecture diagram of the GitHub repository ywjawmw/smgcn-torch-master, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ywjawmw/smgcn-torch-master
- Repository: https://github.com/ywjawmw/smgcn-torch-master

## Overview

##### Project type and purpose
- This is a PyTorch-based machine-learning pipeline implementing SMGCN (a graph convolution-based recommendation model).
- It supports two domains: a traditional Herb–Symptom recommendation dataset and a NetEase bundle–item dataset.
- The goal is to train the SMGCN model, evaluate it on test splits, and dump ranking metrics to the output folder.

##### File structure
- Top-level scripts and configs:
- smgcn_main.py – the entry point for training & evaluation
- SMGCN.sh – shell wrapper to launch experiments
- README.md – usage, dataset specs, dependency list
- Data directory:
- data/Herb – preprocessed Herb/symptom train/test/valid sets and mappings
- data/NetEase – preprocessed user–bundle–item interactions and size metadata
- model directory:
- model/SMGCN.py – PyTorch module defining the SMGCN architecture (graph conv layers, forward pass)
- utils directory:
- load_data.py – builds adjacency matrices and feature tensors from raw text files
- helper.py, utils.py, batch_test.py – evaluation routines, metric computations, negative sampling
- parser.py – hyperparameter search space and argument parsing
- output/result directories:
- output/Herb – result files (.result-*) for Herb experiments
- result (if used) – catch-all for other domains or future extensions

##### README for additional insights
- Lists required Python packages and versions
- Describes how to run training with `python smgcn_main.py`
- Details the format of every dataset file, so you know how load_data constructs inputs

##### Detail without over-splitting
- Layer of abstraction (data loader vs. model vs. trainer).
- Don’t feel obliged to split every helper function—focus on logical components.
- Non-trivial step (e.g., construction of the symptom–herb bipartite graph).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    subgraph "Data Layer"
        RawHerb["Herb Data Files"]:::datastore
        RawNetEase["NetEase Data Files"]:::datastore
    end

    %% Preprocessing & Config
    subgraph "Preprocessing & Config"
        loader["Data Loader & Preprocessor\n(utils/load_data.py)"]:::module
        parser["Configuration & Argument Parser\n(utils/parser.py)"]:::module
        tensors["Adjacency & Feature Tensors"]:::datastructure
    end

    %% Model & Training
    subgraph "Model & Training"
        main["Training Orchestration\n(smgcn_main.py)"]:::module
        shell["Shell Wrapper\n(SMGCN.sh)"]:::module
        model["SMGCN Model Definition\n(model/SMGCN.py)"]:::module
    end

    %% Evaluation & Output
    subgraph "Evaluation & Output"
        eval["Evaluation Module\n(utils/batch_test.py)"]:::module
        helperFuncs["Helper Functions\n(utils/helper.py)"]:::module
        utilsModule["Utility Utils\n(utils/utils.py)"]:::module
        outHerb["Output Directory\n(output/Herb/)"]:::datastore
        outResult["Catch-All Result\n(result/)"]:::datastore
    end

    %% Data Flow
    RawHerb -->|"load_data"| loader
    RawNetEase -->|"load_data"| loader
    loader -->|"build tensors"| tensors
    parser -->|"hyperparams"| main
    tensors -->|"dataset"| main
    main -->|"init model"| model
    shell -->|"launch"| main
    main -->|"train/optimize"| model
    model -->|"forward/backward"| main
    main -->|"trigger evaluation"| eval
    helperFuncs -->|"metrics/neg sampling"| eval
    utilsModule -->|"support routines"| eval
    eval -->|"write results"| outHerb
    eval -->|"write results"| outResult

    %% Click Events
    click main "https://github.com/ywjawmw/smgcn-torch-master/blob/master/smgcn_main.py"
    click shell "https://github.com/ywjawmw/smgcn-torch-master/blob/master/SMGCN.sh"
    click RawHerb "https://github.com/ywjawmw/smgcn-torch-master/tree/master/data/Herb/"
    click RawNetEase "https://github.com/ywjawmw/smgcn-torch-master/tree/master/data/NetEase/"
    click loader "https://github.com/ywjawmw/smgcn-torch-master/blob/master/utils/load_data.py"
    click parser "https://github.com/ywjawmw/smgcn-torch-master/blob/master/utils/parser.py"
    click model "https://github.com/ywjawmw/smgcn-torch-master/blob/master/model/SMGCN.py"
    click eval "https://github.com/ywjawmw/smgcn-torch-master/blob/master/utils/batch_test.py"
    click helperFuncs "https://github.com/ywjawmw/smgcn-torch-master/blob/master/utils/helper.py"
    click utilsModule "https://github.com/ywjawmw/smgcn-torch-master/blob/master/utils/utils.py"
    click outHerb "https://github.com/ywjawmw/smgcn-torch-master/tree/master/output/Herb/"
    click outResult "https://github.com/ywjawmw/smgcn-torch-master/tree/master/result/"

    %% Styles
    classDef datastore fill:#AED6F1,stroke:#2E86C1,color:#1B4F72,stroke-width:1px;
    classDef module fill:#A9DFBF,stroke:#27AE60,color:#145A32,stroke-width:1px;
    classDef datastructure fill:#F9E79F,stroke:#D4AC0D,color:#7D6608,stroke-width:1px;
```
