Coder Social home page Coder Social logo

hgn's Introduction

The HGN model for Sequential Recommendation

The implementation of the paper:

Chen Ma, Peng Kang, and Xue Liu, "Hierarchical Gating Networks for Sequential Recommendation", in the 25th ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD 2019)

Arxiv: https://arxiv.org/abs/1906.09217

Please cite our paper if you use our code. Thanks!

Author: Chen Ma ([email protected])

Feel free to send me an email if you have any questions.

Bibtex

@inproceedings{DBLP:conf/kdd/MaKL19,
  author    = {Chen Ma and
               Peng Kang and
               Xue Liu},
  title     = {Hierarchical Gating Networks for Sequential Recommendation},
  booktitle = {{KDD}},
  pages     = {825--833},
  publisher = {{ACM}},
  year      = {2019}
}

Environments

  • python 3.6
  • PyTorch (version: 1.0.0)
  • numpy (version: 1.15.0)
  • scipy (version: 1.1.0)
  • sklearn (version: 0.19.1)

Dataset

In our experiments, the movielens-20M dataset is from https://grouplens.org/datasets/movielens/20m/, the Amazon-CDs and Amazon-Books datasets are from http://jmcauley.ucsd.edu/data/amazon/, the GoodReads-Children and GoodReads-Comics datasets are from https://sites.google.com/eng.ucsd.edu/ucsdbookgraph/home. (If you need the data after preprocessing, please send me an email check this Google Drive link).

The XXX_tem_sequences.pkl file is a list of lists that stores the inner item id of each user in a chronological order, e.g., user_records[0]=[item_id0, item_id1, item_id2,...].

The XXX_user_mapping.pkl file is a list that maps the user inner id to its original id, e.g., user_mapping[0]=A2SUAM1J3GNN3B.

The XXX_item_mapping.pkl file is similar to XXX_user_mapping.pkl.

Example to run the code

Data preprocessing:

The code for data preprocessing is put in the /preprocessing folder. Amazon_CDs.ipynb provides an example on how to transform the raw data into the .pickle files that used in our program.

Train and evaluate the model (you are strongly recommended to run the program on a machine with GPU):

python run.py

Another implementation

Kindly thank Liwei Wu for another implementation with a different evaluation strategy: https://github.com/wuliwei9278/HGN_baseline.

Acknowledgment

The sequence segmentation (interactions.py) is heavily built on Spotlight. Thanks for the amazing work.

hgn's People

Contributors

ahuiwang avatar allenjack 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  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  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  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  avatar  avatar

hgn's Issues

How to understand shift here?

In def data_index_shift(self, lists, increase_by=2) the explanation is:

Increase the item index to contain the pad_index

In def generate_dataset(self, index_shift=1), return self.num_items + index_shift

How to understant this? Any response is appreciated.

The experimental results are not match the paper results

Hello, I run your code provided, the result of Recall@10 is worse than the paper's, but the NDCG@10 is better than the paper's. And the NDCG@10 is big margin than paper's. Will you update your paper's results in the future?

How to predict New values?

The current model predicts values from the test set.
It there a way to pass our own values through HGN for prediction (from indexes) than creating another test set like that?

Example: How to generate the prediction for a user with their Books_item_Sequences = [427, 1347, 7598, 4876, 32334 ]?

Any help or guidance is appreciated.

A mistake on negative sampling

HGN/run.py

Line 91 in 8bf6008

return np.asarray(neg_samples).reshape(num_sets, train_matrix.shape[0], num_neg)

I think you may change it to this one. Otherwise, positive items can be sampled.

ret = np.asarray(neg_samples).reshape(train_matrix.shape[0], num_sets, num_neg)  # [n_user, ]
return np.transpose(ret, axes=[1, 0, 2])```

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.