Handling Information Loss of Graph Neural Networks for Session-based Recommendation

Overview

LESSR

A PyTorch implementation of LESSR (Lossless Edge-order preserving aggregation and Shortcut graph attention for Session-based Recommendation) from the paper:
Handling Information Loss of Graph Neural Networks for Session-based Recommendation, Tianwen Chen and Raymong Chi-Wing Wong, KDD '20

Requirements

  • PyTorch 1.6.0
  • NumPy 1.19.1
  • Pandas 1.1.3
  • DGL 0.5.2

Usage

  1. Install the requirements.
    If you use Anaconda, you can create a conda environment with the required packages using the following command.

    conda env create -f packages.yml

    Activate the created conda environment.

    conda activate lessr
    
  2. Download and extract the datasets.

  3. Preprocess the datasets using preprocess.py.
    For example, to preprocess the Diginetica dataset, extract the file train-item-views.csv to the folder datasets/ and run the following command:

    python preprocess.py -d diginetica -f datasets/train-item-views.csv

    The preprocessed dataset is stored in the folder datasets/diginetica.
    You can see the detailed usage of preprocess.py by running the following command:

    python preprocess.py -h
  4. Train the model using main.py.
    If no arguments are passed to main.py, it will train a model using a sample dataset with default hyperparameters.

    python main.py

    The commands to train LESSR with suggested hyperparameters on different datasets are as follows:

    python main.py --dataset-dir datasets/diginetica --embedding-dim 32 --num-layers 4
    python main.py --dataset-dir datasets/gowalla --embedding-dim 64 --num-layers 4
    python main.py --dataset-dir datasets/lastfm --embedding-dim 128 --num-layers 4

    You can see the detailed usage of main.py by running the following command:

    python main.py -h
  5. Use your own dataset.

    1. Create a subfolder in the datasets/ folder.
    2. The subfolder should contain the following 3 files.
      • num_items.txt: This file contains a single integer which is the number of items in the dataset.
      • train.txt: This file contains all the training sessions.
      • test.txt: This file contains all the test sessions.
    3. Each line of train.txt and test.txt represents a session, which is a list of item IDs separated by commas. Note the item IDs must be in the range of [0, num_items).
    4. See the folder datasets/sample for an example of a dataset.

Citation

If you use our code in your research, please cite our paper:

@inproceedings{chen2020lessr,
    title="Handling Information Loss of Graph Neural Networks for Session-based Recommendation",
    author="Tianwen {Chen} and Raymond Chi-Wing {Wong}",
    booktitle="Proceedings of the 26th ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD '20)",
    pages="1172-–1180",
    year="2020"
}
Comments
  • question data preprocessing

    question data preprocessing

    Hi, I have a question about data preprocessing. Why you use different process for different dataset? Like, for Diginetica, you didn't remove the immediate repeat. And for gowalla and lastfm, short sessions were not removed. Thanks in advance.

    opened by Rosarubu 8
  • This code chooses best model on test set instead of validation set.

    This code chooses best model on test set instead of validation set.

    At utils/train.py, the train process returns the best MRR and HIT on TEST SET, RESPECTIVELY:

    def train(self, epochs, log_interval=100):
        # ...
        for epoch in range(epochs):
            self.model.train()
            for batch in self.train_loader:
            # ...
            mrr, hit = evaluate(self.model, self.test_loader, self.device)  # mrr and hit on test set
            # ...
            max_mrr = max(max_mrr, mrr)  # best mrr on test set
            max_hit = max(max_hit, hit)  # best hit on test set
            self.epoch += 1
        return max_mrr, max_hit  # <- It's NOT OK to return best mrr and hit on TEST SET, RESPECTIVELY
    

    I believe this code is not the final version, please update it to the code used in your paper.

    opened by zzxn 2
  • Issue the request:RuntimeError

    Issue the request:RuntimeError

    Hi, do you have the following problem? Now the version is corresponding to the same, I don't know where the problem appears, is there any friend who can help solve it? Traceback (most recent call last): File "E:/WorkSpace2--pycharm/lessr-master/main.py", line 85, in runner.train(args.epochs, args.log_interval) File "E:\WorkSpace2--pycharm\lessr-master\utils\train.py", line 105, in train logits = self.model(*inputs) File "E:\requireSoft\anaconda38\lib\site-packages\torch\nn\modules\module.py", line 722, in call_impl result = self.forward(*input, **kwargs) File "E:\WorkSpace2--pycharm\lessr-master\lessr.py", line 171, in forward feat = self.embedding(iid) File "E:\requireSoft\anaconda38\lib\site-packages\torch\nn\modules\module.py", line 722, in call_impl result = self.forward(*input, **kwargs) File "E:\requireSoft\anaconda38\lib\site-packages\torch\nn\modules\sparse.py", line 124, in forward return F.embedding( File "E:\requireSoft\anaconda38\lib\site-packages\torch\nn\functional.py", line 1813, in embedding no_grad_embedding_renorm(weight, input, max_norm, norm_type) File "E:\requireSoft\anaconda38\lib\site-packages\torch\nn\functional.py", line 1733, in no_grad_embedding_renorm torch.embedding_renorm(weight, input, max_norm, norm_type) RuntimeError: Expected tensor for argument #2 'indices' to have scalar type Long; but got torch.IntTensor instead (while checking arguments for embedding_renorm)

    opened by lypingk 0
  • Data preprocessing for youchoose

    Data preprocessing for youchoose

    Please Can You provide dataset preprocessed of youchoose. I can't reproduce results on this dataset. Something maybe wrong on your paper. If I you preprocess youchoose from sr-gnn(https://github.com/CRIPAC-DIG/SR-GNN) the statistics is not same in your paper. And also, Did you ignored session has length higher 20 like you did in the digentical. Thank you.

    opened by dthtuenguyen 1
  • question data preprocessing

    question data preprocessing

    Even if the same preprocessing method is adopted, why is the number of items in diginetica 42596 instead of 43097. Because I see that most studies (such as SR-GNN) use the same preprocessing method, the number of items in diginetica is 43097. Thank you for your attention.

    opened by Sword-CS 1
Owner
Tianwen CHEN
A CS PhD Student in HKUST
Tianwen CHEN
Implementation of a hadoop based movie recommendation system

Implementation-of-a-hadoop-based-movie-recommendation-system 通过编写代码,设计一个基于Hadoop的电影推荐系统,通过此推荐系统的编写,掌握在Hadoop平台上的文件操作,数据处理的技能。windows 10 hadoop 2.8.3 p

汝聪(Ricardo) 5 Oct 2, 2022
A Python implementation of LightFM, a hybrid recommendation algorithm.

LightFM Build status Linux OSX (OpenMP disabled) Windows (OpenMP disabled) LightFM is a Python implementation of a number of popular recommendation al

Lyst 4.2k Jan 2, 2023
A TensorFlow recommendation algorithm and framework in Python.

TensorRec A TensorFlow recommendation algorithm and framework in Python. NOTE: TensorRec is not under active development TensorRec will not be receivi

James Kirk 1.2k Jan 4, 2023
Persine is an automated tool to study and reverse-engineer algorithmic recommendation systems.

Persine, the Persona Engine Persine is an automated tool to study and reverse-engineer algorithmic recommendation systems. It has a simple interface a

Jonathan Soma 87 Nov 29, 2022
ToR[e]cSys is a PyTorch Framework to implement recommendation system algorithms

ToR[e]cSys is a PyTorch Framework to implement recommendation system algorithms, including but not limited to click-through-rate (CTR) prediction, learning-to-ranking (LTR), and Matrix/Tensor Embedding. The project objective is to develop a ecosystem to experiment, share, reproduce, and deploy in real world in a smooth and easy way (Hope it can be done).

LI, Wai Yin 90 Oct 8, 2022
A framework for large scale recommendation algorithms.

A framework for large scale recommendation algorithms.

Alibaba Group - PAI 880 Jan 3, 2023
Recommendation System to recommend top books from the dataset

recommendersystem Recommendation System to recommend top books from the dataset Introduction The recom.py is the main program code. The dataset is als

Vishal karur 1 Nov 15, 2021
An open source movie recommendation WebApp build by movie buffs and mathematicians that uses cosine similarity on the backend.

Movie Pundit Find your next flick by asking the (almost) all-knowing Movie Pundit Jump to Project Source » View Demo · Report Bug · Request Feature Ta

Kapil Pramod Deshmukh 8 May 28, 2022
Books Recommendation With Python

Books-Recommendation Business Problem During the last few decades, with the rise

Çağrı Karadeniz 7 Mar 12, 2022
Bert4rec for news Recommendation

News-Recommendation-system-using-Bert4Rec-model Bert4rec for news Recommendation

saran pandian 2 Feb 4, 2022
E-Commerce recommender demo with real-time data and a graph database

?? E-Commerce recommender demo ?? This is a simple stream setup that uses Memgraph to ingest real-time data from a simulated online store. Data is str

g-despot 3 Feb 23, 2022
QRec: A Python Framework for quick implementation of recommender systems (TensorFlow Based)

QRec is a Python framework for recommender systems (Supported by Python 3.7.4 and Tensorflow 1.14+) in which a number of influential and newly state-of-the-art recommendation models are implemented. QRec has a lightweight architecture and provides user-friendly interfaces. It can facilitate model implementation and evaluation.

Yu 1.4k Dec 27, 2022
Plex-recommender - Get movie recommendations based on your current PleX library

plex-recommender Description: Get movie/tv recommendations based on your current

null 5 Jul 19, 2022
ANKIT-OS/TG-SESSION-GENERATOR-BOTbisTG-SESSION-GENERATOR-BOT a special repository. Its Is A Telegram Bot To Generate String Session

ANKIT-OS/TG-SESSION-GENERATOR-BOTbisTG-SESSION-GENERATOR-BOT a special repository. Its Is A Telegram Bot To Generate String Session

ANKIT KUMAR 1 Dec 26, 2021
Official public repository of paper "Intention Adaptive Graph Neural Network for Category-Aware Session-Based Recommendation"

Intention Adaptive Graph Neural Network (IAGNN) This is the official repository of paper Intention Adaptive Graph Neural Network for Category-Aware Se

null 9 Nov 22, 2022
Codes for CIKM'21 paper 'Self-Supervised Graph Co-Training for Session-based Recommendation'.

COTREC Codes for CIKM'21 paper 'Self-Supervised Graph Co-Training for Session-based Recommendation'. Requirements: Python 3.7, Pytorch 1.6.0 Best Hype

Xin Xia 42 Dec 9, 2022
Implementation of some unbalanced loss like focal_loss, dice_loss, DSC Loss, GHM Loss et.al

Implementation of some unbalanced loss for NLP task like focal_loss, dice_loss, DSC Loss, GHM Loss et.al Summary Here is a loss implementation reposit

null 121 Jan 1, 2023
FastAPI Server Session is a dependency-based extension for FastAPI that adds support for server-sided session management

FastAPI Server-sided Session FastAPI Server Session is a dependency-based extension for FastAPI that adds support for server-sided session management.

DevGuyAhnaf 5 Dec 23, 2022
Implement of "Training deep neural networks via direct loss minimization" in PyTorch for 0-1 loss

This is the implementation of "Training deep neural networks via direct loss minimization" published at ICML 2016 in PyTorch. The implementation targe

Cuong Nguyen 1 Jan 18, 2022
ANKIT-OS/TG-SESSION-HACK-BOT: A Special Repository.Telegram Bot Which Can Hack The Victim By Using That Victim Session

?? ᵀᴱᴸᴱᴳᴿᴬᴹ ᴴᴬᶜᴷ ᴮᴼᵀ ?? The owner would not be responsible for any kind of bans due to the bot. • ⚡ INSTALLING ⚡ • • ??️ Lᴀɴɢᴜᴀɢᴇs Aɴᴅ Tᴏᴏʟs ?? • If

ANKIT KUMAR 2 Dec 24, 2021