GithubHelp home page GithubHelp logo

skywalker518 / a-recsys Goto Github PK

View Code? Open in Web Editor NEW
107.0 16.0 43.0 5.75 MB

A Tensorflow based implicit recommender system

Python 100.00%
recsys tensorflow attribute-embedding sequence-models metadata lstm

a-recsys's Introduction

A-RecSys : a Tensorflow Toolkit for Implicit Recommendation Tasks

A-RecSys

A-RecSys implements implicit recommendation algorithms and is designed for large scale recommendation settings. It extends traditional matrix factorization algorithms, and focuses on attribute embedding and applying sequence models.

Works implemented by this toolkit include:

  • A Batch Learning Framework for Scalable Personalized Ranking. AAAI 18. arXiv
  • Sequential heterogeneous attribute embedding for item recommendation. ICDM 17 SERecsys Workshop.
  • Temporal Learning and Sequence Modeling for a Job Recommender System. RecSys Challenge 16 pdf

The models and features supported by A-RecSys include,

Models

  • Hybrid matrix factorization model (with deep layer extensions)
  • Linear sequence models based on CBOW and skip-gram
  • LSTM-based seq2seq model

Features

  • Recommendation with implicit feedback
  • Heterogeneous attribute embedding (see attributes/README.md for details)
  • Objective functions include cross-entropy, Weighted Margin Rank Batch loss.

How to use

Input data

CSV-formated (sep=\t) input files include

u.csv	: user file. user id and attribute values.
i.csv: item file. item id and attribute values.
obs_tr.csv: implicit feedback for training. First two columns are user-id, item-id. Third column (optional) is for timestamp. 
obs_va.csv: implicit feedback for development.
obs_te.csv: implicit feedback for testing.

A example (adapted from MovieLens 1m) is given at ./examples/dataset/

Train models

Example scripts are provided at ./examples/ to start running the code

To train hybrid matrix factorization model on provided MovieLens 1m dataset:

cd examples/
bash run_hmf.sh 32 1 False 100 False

To train lstm model:

cd examples/
bash run_lstm.sh 64 1 False

(Code has been tested on TF 0.8 and above.)

Recommend

You can switch to "recommend" mode from "training" by setting flag recommend to 'true'. In the above HMF example, it would be:

cd examples/
bash run_hmf.sh 32 1 False 100 True

By default, the code generates a ground truth interaction file res_T_test.csv from obs_te.csv, and perform recommendation on all users that appear in res_T_test.csv. You can generate your own res_T_test.csv to narrow down user set to identify which recommendation is being performed.

Dependencies

The code now supports Tensorflow v1.0. During our development, the code was tested with versions 0.8, 0.9, 0.11, 0.12.

Cite

Please cite the following if you find this helpful.

@inproceedings{liu2017wmrb, title={WMRB: learning to rank in a scalable batch training approach}, author={Liu, Kuan and Natarajan, Prem}, booktitle={Proceedings of the Recommender Systems Poster}, year={2017}, organization={ACM} }

@inproceedings{liu2016temporal, title={Temporal learning and sequence modeling for a job recommender system}, author={Liu, Kuan and Shi, Xing and Kumar, Anoop and Zhu, Linhong and Natarajan, Prem}, booktitle={Proceedings of the Recommender Systems Challenge}, pages={7}, year={2016}, organization={ACM} }

Feedback

Your comments and suggestions are more than welcome! We really appreciate that!

Kuan Liu [email protected] Xing Shi [email protected]

a-recsys's People

Contributors

bryanchan777 avatar shixing avatar skywalker518 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

a-recsys's Issues

Shapes are incompatible

I use tensorflow r0.12 to run ml-1m dataset and i get the following error.

Traceback (most recent call last):
File "/home/endy/PycharmProjects/recommender/lstm/run.py", line 720, in
main()
File "/home/endy/PycharmProjects/recommender/lstm/run.py", line 717, in main
train()
File "/home/endy/PycharmProjects/recommender/lstm/run.py", line 360, in train
train_set, dev_set, test_set, embAttr, START_ID, item_population, p_item, _, _ = read_data(task)
File "/home/endy/PycharmProjects/recommender/lstm/run.py", line 299, in read_data
embAttr = embed_attribute.EmbeddingAttribute(u_attr, i_attr, FLAGS.batch_size, FLAGS.n_sampled, _buckets[-1], FLAGS.use_sep_item, item_ind2logit_ind, logit_ind2item_ind, devices=devices)
File "/home/endy/PycharmProjects/recommender/lstm/attributes/embed_attribute.py", line 116, in init
self.update_sampled = self._pass_sampled_items(prefix, device=devices[-1])
File "/home/endy/PycharmProjects/recommender/lstm/attributes/embed_attribute.py", line 337, in _pass_sampled_items
mulhot_indices = batch_slice2(self.att[prefix][1][i], b, s, self.n_sampled)
File "/home/endy/PycharmProjects/recommender/lstm/attributes/mulhot_index.py", line 46, in batch_slice2
return tf.concat(res, 0)
File "/home/endy/.virtualenvs/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1122, in concat
).assert_is_compatible_with(tensor_shape.scalar())
File "/home/endy/.virtualenvs/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_shape.py", line 756, in assert_is_compatible_with
raise ValueError("Shapes %s and %s are incompatible" % (self, other))
ValueError: Shapes (1024, ?) and () are incompatible

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.