This package implements the the method of "regularization differentiating function" (RDF). In particular, we apply RDF on the following three recommendation models: SVD, SVD++, and NMF.
If you find the library useful, please cite the following article.
Chen, Hung-Hsuan, and Pu Chen. "Differentiating Regularization Weights--A Simple Mechanism to Alleviate Cold Start in Recommender Systems." ACM Transactions on Knowledge Discovery from Data (TKDD) 13.1 (2019).
Paper download: https://in.ncu.edu.tw/~hhchen/academic_works/chen19_diff_reg_weight.pdf
>>> import rdf
>>> X = rdf.utils.load_data('./data/filmtrust/train.dat')
>>> n_users, n_items = rdf.utils.get_num_users_items(X)
>>> m = rdf.rdfsvd.RDFSVD(
... n_users=n_users, n_items=n_items, lr=.005,
... lmbda_p=500, lmbda_q=500,
... lmbda_u=.01, lmbda_i=.01,
... method="linear")
>>> m.train(X)
>>> X_test = rdf.utils.load_data('./data/filmtrust/test.dat')
>>> X_pred = m.predict(X_test)
>>> rdf.utils.compute_rmse(X_test, X_pred)
python setup.py install
After installation, you may run the following scripts directly (tested in Ubuntu 16.04 and OS X El Capitan).
rdfsvd-train.py -tr [train-file] -m [model-file]
This will run SVD with RDF and generate a model file of the name [train-file]-rdfsvd-model.pck
under the same directory.
The [train-file]
contains the training samples, i.e., a list of (user-id, item-id, rating), one tuple per line.
Similarly, you may use the command rdfsvdpp-train.py
, rdfnmf-train.py
to generate the SVD++ model with RDF and NMF model with RDF.
We also include the SVD model, SVD++ model, and NMF model without RDF. You may execute these models by running svd-train.py
, svdpp-train.py
, and nmf-train.py
.
rdf-test.py -te [test-file] -m [model-file]
The [test-file]
contains a list of (user-id, item-id, rating), one tuple per line.
The [model-file]
is the model file generated by, for example, rdfsvd-train.py
.