GithubHelp home page GithubHelp logo

criteo-research / cause Goto Github PK

View Code? Open in Web Editor NEW
246.0 14.0 54.0 28 KB

Code for the Recsys 2018 paper entitled Causal Embeddings for Recommandation.

License: Apache License 2.0

Python 100.00%
tensorflow embeddings causal-inference causality

cause's Introduction

CausE

Python code for the RecSys 2018 paper entitled 'Causal Embeddings for Recommendation' using Tensorflow. A pre-print version of the paper can be found here - https://arxiv.org/abs/1706.07639

Code Organisation

The code is organized as follows:

  • causal_prod2vec.py - Used to run the CausE-avg method from the paper, where users response under the uniform exposure is averaged into a single vector.
  • causal_prod2vec2i.py - Used to run the CausE-prod-T and CausE-prod-C methods from the paper, where users response under the uniform exposure is mapped into a separate product matrix.
  • models.py - SupervisedProd2Vec and CausalProd2Vec as tensorflow model classes.
  • dataset_loading.py - File to load Movielens/Netflix datasets and convert to user/product matrix.
  • utils.py - Various helper methods.

Dependencies and Requirements

The code has been designed to support python 3.6+ only. The project has the following dependences and version requirements:

  • python3 - 3.6.5+
  • tensorflow - 1.9.0+
  • tensorboard - 1.9.0+
  • numpy - 1.14.5+
  • scipy - 1.1+
  • pandas - 0.22+

Training a Model

After the data has been downloaded, preprocessed and placed in the Data directory, the models can then be training simply by running python3 causal_prod2vec.py or python3 causal_prod2vec2i.py from the src directory. The various hyper-parameters of the models can be controlled via arguments detailed below.

Optional arguments

The code uses TF flags to manage the command line arguments for running the models, please note that both models have the same parameters.

Causal Embeddings for Recommendation Parameters

optional arguments:
--data_set : The dataset to load
--model_name : The name of the model used when saving (default: cp2v)
--logging_dir : Where to save tensorboard data (default: /tmp/tensorboard/)
--learning_rate : The learning rate for SGD (default: 1.0)
--l2_pen : The weight decay regularization amount (default: 0.0)
--num_epochs : The number of epochs to train for (default: 10)
--batch_size : The batch size for SGD (default: 512)
--num_steps : The number of batches after which to print information (default: 500)
--early_stopping_enabled : If to use early stopping (default: False)
--early_stopping : 'Tolerance for early stopping (# of epochs).' (default: 200)
--embedding_size : The embeddings dimension of the product and user embeddings (default: 50)
--cf_pen : The weighting for the counter-factual regularization (default: 1.0)
--cf_distance : Which distance metric to use for the counter-factual regularization (default: l1)

Cite

Please cite the associated paper for this work if you use this code:

@inproceedings{bonner2018causal,
  title={Causal embeddings for recommendation},
  author={Bonner, Stephen and Vasile, Flavian},
  booktitle={Proceedings of the 12th ACM Conference on Recommender Systems},
  pages={104--112},
  year={2018},
  organization={ACM}
}

License

Copyright CRITEO

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

cause's People

Contributors

sbonner0 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

cause's Issues

Missing gen_dataset.py script

Hi, first of all, I read your paper which is really nice and thanks for releasing the code. However, I cannot find the file 'gen_dataset.py' described in the README file of this repo, so I'm wondering if it is possible for providing this file as well.

how to preprocess data

dataset_loading.py will create ML_view.txt
but causal_prod2vec.py need .csv
could you upload the preprocess code plz.

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.