This package implements the Behavior2Vec
algorithm introduced in the following paper.
Please cite the paper if you find this package useful.
Chen, Hung-Hsuan. "Behavior2Vec: Generating Distributed Representations of Users’ Behaviors on Products for Recommender Systems." ACM Transactions on Knowledge Discovery from Data (TKDD) 12.4 (2018).
BibTeX:
@article{chen2018behavior2vec, title={Behavior2Vec: Generating Distributed Representations of Users’ Behaviors on Products for Recommender Systems}, author={Chen, Hung-Hsuan}, journal={ACM Transactions on Knowledge Discovery from Data (TKDD)}, volume={12}, issue={4}, year={2018}, publisher={ACM} }
Paper download:
- URL1: http://in.ncu.edu.tw/~hhchen/academic_works/chen18-tkdd-b2v.pdf
- URL2: https://dl.acm.org/citation.cfm?id=3184454
>>> import behavior2vec
>>> model = behavior2vec.Behavior2Vec()
>>> model.train('./data/sample_data.txt') # log file, one line per user (session)
>>> model.most_similar_behavior('v-100', 'p', k=5) # predict most similar p-type (purchasing) behavior to 'v-100' (view item 100)
>>> model.most_similar_item('100', k=5) # predict most similar items to item 100
python setup.py install
After installation, you may run the following scripts directly (tested in Ubuntu 16.04 and OS X El Capitan).
b2v-train.py [train-file]
This will generate a model file of the name [train-file]-b2v-model.pck
under the same directory.
b2v-most-similar-behavior.py [test-file] [model-file] [output-file] [k] [behavior-type]
The [test-file]
contains a list of query behaviors, one behavior per line.
The [output-file]
is the output file, which contains a list of the top [k]
most simiar behaviors
b2v-most-similar-item.py [test-file] [model-file] [output-file] [k]
The [test-file]
contains a list of query items, one behavior per line.
The [output-file]
is the output file, which contains a list of the top [k]
most simiar items