# rdevooght/sequence-based-recommendations architecture

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

- Interactive diagram: https://gitdiagram.com/rdevooght/sequence-based-recommendations
- Repository: https://github.com/rdevooght/sequence-based-recommendations

## Overview

##### Main System Components

The system should be divided into four main component groups:

a) Core Algorithm Modules:
- Factorization-based methods
- Neural Network-based methods
- Lazy (Memory-based) methods
- Word2Vec-based methods

b) Support Infrastructure:
- Data preprocessing pipeline
- Training pipeline
- Testing/Evaluation pipeline

c) Helper Components:
- Command parsing
- Data handling
- Evaluation metrics
- Early stopping mechanisms

d) Model Management:
- Model persistence
- Results storage
- Dataset management

##### Specific Implementation Details

For each major component, include:

a) Factorization Methods:
- BPRMF
- FISM
- FOSSIL
- FPMC
- Shared base classes and inheritance

b) Neural Networks:
- RNN variants (LSTM, GRU, Vanilla)
- Stacked Denoising Autoencoder
- Clustering capabilities

c) Lazy Methods:
- Markov Model
- User KNN
- Popularity-based

##### Connection Types

- Data flow
- Inheritance relationships
- Dependencies
- Training/inference paths

##### Key Elements to Highlight

- The modular nature of the algorithm implementations
- The shared infrastructure between different methods
- The separation between training and inference paths
- The data preprocessing pipeline
- The evaluation metrics system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Pipeline
        Preprocess["Preprocess"]:::preprocess
        Train["Train"]:::train
        Test["Test"]:::test
        Preprocess --> Train
        Train --> Test
    end

    subgraph "Core Algorithms"
        subgraph "Factorization Methods"
            MFBase["Matrix Factorization Base"]:::factorization
            BPRMF["BPRMF"]:::factorization
            FISM["FISM"]:::factorization
            FOSSIL["FOSSIL"]:::factorization
            FPMC["FPMC"]:::factorization
            
            MFBase --> BPRMF
            MFBase --> FISM
            MFBase --> FOSSIL
            MFBase --> FPMC
        end

        subgraph "Neural Networks"
            RNNBase["RNN Base"]:::neural
            RNNCluster["RNN Cluster"]:::neural
            RNNMargin["RNN Margin"]:::neural
            RNNOneHot["RNN One Hot"]:::neural
            RNNSampling["RNN Sampling"]:::neural
            SDA["Stacked Denoising Autoencoder"]:::neural
            RecurrentLayers["Recurrent Layers"]:::neural

            RNNBase --> RNNCluster
            RNNBase --> RNNMargin
            RNNBase --> RNNOneHot
            RNNBase --> RNNSampling
            RecurrentLayers --> RNNBase
        end

        subgraph "Lazy Methods"
            MarkovModel["Markov Model"]:::lazy
            UserKNN["User KNN"]:::lazy
            Pop["Popularity-based"]:::lazy
        end

        subgraph "Word2Vec Methods"
            LTM["LTM"]:::word2vec
        end
    end

    subgraph "Helper Components"
        CommandParser["Command Parser"]:::helper
        DataHandling["Data Handling"]:::helper
        EarlyStopping["Early Stopping"]:::helper
        Evaluation["Evaluation Metrics"]:::helper
        SparseLayer["Sparse Layer"]:::helper
    end

    Train --> MFBase
    Train --> RNNBase
    Train --> MarkovModel
    Train --> UserKNN
    Train --> Pop
    Train --> LTM

    DataHandling --> Train
    EarlyStopping --> Train
    CommandParser --> Train
    Evaluation --> Test
    SparseLayer --> Train

    classDef preprocess fill:#90EE90
    classDef train fill:#ADD8E6
    classDef test fill:#FFB6C1
    classDef factorization fill:#4169E1
    classDef neural fill:#1E90FF
    classDef lazy fill:#87CEEB
    classDef word2vec fill:#6495ED
    classDef helper fill:#FFD700

    click Preprocess "https://github.com/rdevooght/sequence-based-recommendations/blob/master/preprocess.py"
    click Train "https://github.com/rdevooght/sequence-based-recommendations/blob/master/train.py"
    click Test "https://github.com/rdevooght/sequence-based-recommendations/blob/master/test.py"
    click BPRMF "https://github.com/rdevooght/sequence-based-recommendations/blob/master/factorization/bprmf.py"
    click FISM "https://github.com/rdevooght/sequence-based-recommendations/blob/master/factorization/fism.py"
    click FOSSIL "https://github.com/rdevooght/sequence-based-recommendations/blob/master/factorization/fossil.py"
    click FPMC "https://github.com/rdevooght/sequence-based-recommendations/blob/master/factorization/fpmc.py"
    click MFBase "https://github.com/rdevooght/sequence-based-recommendations/blob/master/factorization/mf_base.py"
    click RNNBase "https://github.com/rdevooght/sequence-based-recommendations/blob/master/neural_networks/rnn_base.py"
    click RNNCluster "https://github.com/rdevooght/sequence-based-recommendations/blob/master/neural_networks/rnn_cluster.py"
    click RNNMargin "https://github.com/rdevooght/sequence-based-recommendations/blob/master/neural_networks/rnn_margin.py"
    click RNNOneHot "https://github.com/rdevooght/sequence-based-recommendations/blob/master/neural_networks/rnn_one_hot.py"
    click RNNSampling "https://github.com/rdevooght/sequence-based-recommendations/blob/master/neural_networks/rnn_sampling.py"
    click SDA "https://github.com/rdevooght/sequence-based-recommendations/blob/master/neural_networks/stacked_denoising_autoencoder.py"
    click RecurrentLayers "https://github.com/rdevooght/sequence-based-recommendations/blob/master/neural_networks/recurrent_layers.py"
    click MarkovModel "https://github.com/rdevooght/sequence-based-recommendations/blob/master/lazy/markov_model.py"
    click UserKNN "https://github.com/rdevooght/sequence-based-recommendations/blob/master/lazy/user_knn.py"
    click Pop "https://github.com/rdevooght/sequence-based-recommendations/blob/master/lazy/pop.py"
    click LTM "https://github.com/rdevooght/sequence-based-recommendations/blob/master/word2vec/ltm.py"
    click CommandParser "https://github.com/rdevooght/sequence-based-recommendations/blob/master/helpers/command_parser.py"
    click DataHandling "https://github.com/rdevooght/sequence-based-recommendations/blob/master/helpers/data_handling.py"
    click EarlyStopping "https://github.com/rdevooght/sequence-based-recommendations/blob/master/helpers/early_stopping.py"
    click Evaluation "https://github.com/rdevooght/sequence-based-recommendations/blob/master/helpers/evaluation.py"
    click SparseLayer "https://github.com/rdevooght/sequence-based-recommendations/blob/master/helpers/sparse_layer.py"
```
