GithubHelp home page GithubHelp logo

qitianwu / idcf Goto Github PK

View Code? Open in Web Editor NEW
25.0 3.0 6.0 81 KB

Code for ICML21 spotlight paper "Towards open-world recommendation: An inductive model-based collaborative filtering approach"

Python 100.00%
graph-neural-networks out-of-distribution-generalization pytorch recommender-system

idcf's Introduction

InDuctive Collaborative Filtering (IDCF)

Code and data used in ICML'21 spotlight paper Towards Open-World Recommendation: An Inductive Model-Based Collaborative Filtering Apparoach. There is a Chinese tutorial Blog that introduces this work in an easy-to-follow manner.

This work proposes a new collaborative filtering approach for recsys. The new method could achieve inductive learning for new users in testing set and also help to address cold-start problem on user side.

image

Dependency

Python 3.8, Pytorch 1.7, Pytorch Geometric 1.6

Download trained model and data

The trained model and preprocessed data can be downloaded by the Google drive

https://drive.google.com/drive/folders/1rTfOKZJ-zYrNY9hDUtU9H-UG9fPPQOds?usp=sharing

You can make a directory ./data in the root and download the data into it.

Reproduce results

To reproduce the results in our paper (i.e. Table 2, 3, 4), you need to first download the trained model and data to corresponding folders and run the test.py script in each folder. Take Movielens-1M dataset as an example. You need to first download the folder data/ml-1m.pkl from the Google drive to ./data in your own computer and download model/ml-1m/ to ./code/ml-1m/ in your computer. Then you can run

python ./code/ml-1m/IDCF-NN/test-1m.py

to reproduce the results of IDCF-NN model on few-shot query users on Movielens-1M. Also, you can run

python ./code/ml-1m/IDCF-NN/test-1m.py --extra

to reproduce the results of IDCF-NN model on zero-shot new users on Movielens-1M.

Run the code for training

Our model needs a two-stage training. To train the model from the beginning, you can run two scripts in order.

First, you need to run

python ./code/ml-1m/IDCF-NN/pretrain-1m.py

to pretrain the matrix factorization model. Alternatively, you can skip the pretrain stage by directly using our pretrained model, i.e., download the model file from the path model/ml-1m/IDCF-NN/pretrain-1m/model.pkl in the Google drive to ./code/ml-1m/IDCF-NN/pretrain-1m/model.pkl in your computer.

Second, you need to run the script train-1m.py.

python ./code/ml-1m/IDCF-NN/train-1m.py

Also, in our paper, we consider two scenarios: inductive learning for interpolation (for few-shot query users) and inductive learning for extrapolation (for new test users). For running the former case, you need to set the variable EXTRA as False in train-1m.py. For the latter case, you can set EXTRA=True in train-1m.py.

For model details, please refer to our paper. If you have any question, feel free to contact via email.

If you found the codes or datasets useful, please consider cite our paper:

    @inproceedings{wu2021idcf,
    title = {Towards Open-World Recommendation: An Inductive Model-Based Collaborative Filtering Apparoach},
    author = {Qitian Wu and Hengrui Zhang and Xiaofeng Gao and Junchi Yan and Hongyuan Zha},
    booktitle = {International Conference on Machine Learning (ICML)},
    year = {2021}
    }

idcf's People

Contributors

qitianwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

idcf's Issues

Why does loss_r_test become larger and larger when pre-training?

I'm training ml-1m.
Part of the outputs are shown below:

Epoch 93 Step 76704: Train 0.3622 Reg: 0.4783
Test: 0.9648 MAE: 0.7485 RMSE: 0.9823
Val: 0.9936 MAE: 0.7561 RMSE: 0.9968
Epoch 94 Step 77520: Train 0.3618 Reg: 0.4776
Test: 0.9654 MAE: 0.7486 RMSE: 0.9826
Val: 0.9943 MAE: 0.7562 RMSE: 0.9971
Epoch 95 Step 78336: Train 0.3614 Reg: 0.4769
Test: 0.9659 MAE: 0.7484 RMSE: 0.9828
Val: 0.9948 MAE: 0.7561 RMSE: 0.9974
Epoch 96 Step 79152: Train 0.3611 Reg: 0.4763
Test: 0.9665 MAE: 0.7489 RMSE: 0.9831
Val: 0.9955 MAE: 0.7566 RMSE: 0.9978
Epoch 97 Step 79968: Train 0.3608 Reg: 0.4757
Test: 0.9673 MAE: 0.7495 RMSE: 0.9835
Val: 0.9963 MAE: 0.7572 RMSE: 0.9982
Epoch 98 Step 80784: Train 0.3605 Reg: 0.4751
Test: 0.9676 MAE: 0.7494 RMSE: 0.9837
Val: 0.9967 MAE: 0.7571 RMSE: 0.9983
Epoch 99 Step 81600: Train 0.3603 Reg: 0.4746
Test: 0.9680 MAE: 0.7494 RMSE: 0.9839
Val: 0.9970 MAE: 0.7571 RMSE: 0.9985

As you can see, loss_r_test grew from 0.9648 to 0.9680. In fact, it started to be abnormal after epoch 13.

Epoch 10 Step 8976: Train 0.7002 Reg: 0.5511
Test: 0.7185 MAE: 0.6660 RMSE: 0.8476
Val: 0.7338 MAE: 0.6722 RMSE: 0.8566
Epoch 11 Step 9792: Train 0.6809 Reg: 0.5869
Test: 0.7136 MAE: 0.6643 RMSE: 0.8447
Val: 0.7276 MAE: 0.6705 RMSE: 0.8530
Epoch 12 Step 10608: Train 0.6638 Reg: 0.6277
Test: 0.7109 MAE: 0.6614 RMSE: 0.8431
Val: 0.7244 MAE: 0.6667 RMSE: 0.8511
Epoch 13 Step 11424: Train 0.6438 Reg: 0.6702
Test: 0.7085 MAE: 0.6602 RMSE: 0.8417
Val: 0.7217 MAE: 0.6654 RMSE: 0.8495
Epoch 14 Step 12240: Train 0.6232 Reg: 0.6993
Test: 0.7114 MAE: 0.6602 RMSE: 0.8435
Val: 0.7256 MAE: 0.6661 RMSE: 0.8518
Epoch 15 Step 13056: Train 0.6061 Reg: 0.7176
Test: 0.7164 MAE: 0.6620 RMSE: 0.8464
Val: 0.7304 MAE: 0.6671 RMSE: 0.8547

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.