All Projects → WindQAQ → tf-recsys

WindQAQ / tf-recsys

Licence: MIT license
tf-recsys contains collaborative filtering (CF) model based on famous SVD and SVD++ algorithm. Both of them are implemented by tensorflow in order to utilize GPU acceleration.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to tf-recsys

Recommender-Systems-with-Collaborative-Filtering-and-Deep-Learning-Techniques
Implemented User Based and Item based Recommendation System along with state of the art Deep Learning Techniques
Stars: ✭ 41 (-54.95%)
Mutual labels:  collaborative-filtering, recommender-system, movielens-dataset
Rsparse
Fast and accurate machine learning on sparse matrices - matrix factorizations, regression, classification, top-N recommendations.
Stars: ✭ 145 (+59.34%)
Mutual labels:  collaborative-filtering, recommender-system, svd
Tf-Rec
Tf-Rec is a python💻 package for building⚒ Recommender Systems. It is built on top of Keras and Tensorflow 2 to utilize GPU Acceleration during training.
Stars: ✭ 18 (-80.22%)
Mutual labels:  recommender-system, svd, svdplusplus
Movie Recommender System
Basic Movie Recommendation Web Application using user-item collaborative filtering.
Stars: ✭ 85 (-6.59%)
Mutual labels:  collaborative-filtering, recommender-system
Recommend
Python 3.6 下的推荐算法解析,尽量使用简单的语言剖析原理,相似度度量、协同过滤、矩阵分解等
Stars: ✭ 72 (-20.88%)
Mutual labels:  collaborative-filtering, svd
Neural collaborative filtering
Neural Collaborative Filtering
Stars: ✭ 1,243 (+1265.93%)
Mutual labels:  collaborative-filtering, recommender-system
Consimilo
A Clojure library for querying large data-sets on similarity
Stars: ✭ 54 (-40.66%)
Mutual labels:  collaborative-filtering, recommender-system
Polara
Recommender system and evaluation framework for top-n recommendations tasks that respects polarity of feedbacks. Fast, flexible and easy to use. Written in python, boosted by scientific python stack.
Stars: ✭ 205 (+125.27%)
Mutual labels:  collaborative-filtering, recommender-system
Enmf
This is our implementation of ENMF: Efficient Neural Matrix Factorization (TOIS. 38, 2020). This also provides a fair evaluation of existing state-of-the-art recommendation models.
Stars: ✭ 96 (+5.49%)
Mutual labels:  collaborative-filtering, recommender-system
slopeone
PHP implementation of the Weighted Slope One rating-based collaborative filtering scheme.
Stars: ✭ 85 (-6.59%)
Mutual labels:  collaborative-filtering, recommender-system
Movielens Recommender
A pure Python implement of Collaborative Filtering based on MovieLens' dataset.
Stars: ✭ 131 (+43.96%)
Mutual labels:  collaborative-filtering, recommender-system
Collaborativememorynetwork
Collaborative Memory Network for Recommendation Systems, SIGIR 2018
Stars: ✭ 170 (+86.81%)
Mutual labels:  collaborative-filtering, recommender-system
Rankfm
Factorization Machines for Recommendation and Ranking Problems with Implicit Feedback Data
Stars: ✭ 71 (-21.98%)
Mutual labels:  collaborative-filtering, recommender-system
Gorse
An open source recommender system service written in Go
Stars: ✭ 1,148 (+1161.54%)
Mutual labels:  collaborative-filtering, recommender-system
Recommender System
A developing recommender system in tensorflow2. Algorithm: UserCF, ItemCF, LFM, SLIM, GMF, MLP, NeuMF, FM, DeepFM, MKR, RippleNet, KGCN and so on.
Stars: ✭ 227 (+149.45%)
Mutual labels:  collaborative-filtering, recommender-system
Collaborative Deep Learning For Recommender Systems
The hybrid model combining stacked denoising autoencoder with matrix factorization is applied, to predict the customer purchase behavior in the future month according to the purchase history and user information in the Santander dataset.
Stars: ✭ 60 (-34.07%)
Mutual labels:  collaborative-filtering, recommender-system
Deep Learning For Recommendation Systems
This repository contains Deep Learning based articles , paper and repositories for Recommender Systems
Stars: ✭ 2,493 (+2639.56%)
Mutual labels:  collaborative-filtering, recommender-system
disentangled graph collaborative filtering
Disentagnled Graph Collaborative Filtering, SIGIR2020
Stars: ✭ 118 (+29.67%)
Mutual labels:  collaborative-filtering, recommender-system
Recoder
Large scale training of factorization models for Collaborative Filtering with PyTorch
Stars: ✭ 46 (-49.45%)
Mutual labels:  collaborative-filtering, recommender-system
Elliot
Comprehensive and Rigorous Framework for Reproducible Recommender Systems Evaluation
Stars: ✭ 49 (-46.15%)
Mutual labels:  collaborative-filtering, recommender-system

tf-recsys

Overview

tf-recsys contains collaborative filtering (CF) model based on famous SVD and SVD++ algorithm. Both of them are implemented by Tensorflow in order to utilize GPU acceleration.

Installation

pip install tfcf

Note that if you want to use GPU, please pre-install Tensorflow with GPU version, that is, run

pip install tensorflow-gpu

or follow the instructions at Installing Tensorflow.

Algorithms

SVD

SVD algorithm does matrix factorization via the following formula:

SVD

LHS is the prediction rating. The objective function is summation of the L2 loss between prediction and real rating and the regularization terms. For parameter updating, the gradient descent is used to minimize objective function.

SVD++

Similar to SVD, the original SVD++ algorithm incorporate implicit feedback of users.

SVD++

The implicit feedback of user here is the set of implicit feedback of users.

In this package, we also provide dual option for SVD++, or incoporate the implicit feedback of items. The equation can be re-written as follows:

dual SVD++

where implicit feedback of item is the set of implicit feedback of items.

In our experiments, dual SVD++ outperform both original SVD++ and SVD but with slower training procedure.

Example

import numpy as np
import tensorflow as tf
from tfcf.metrics import mae
from tfcf.metrics import rmse
from tfcf.datasets import ml1m
from tfcf.config import Config
from tfcf.models.svd import SVD
from tfcf.models.svd import SVDPP
from sklearn.model_selection import train_test_split

# Note that x is a 2D numpy array, 
# x[i, :] contains the user-item pair, and y[i] is the corresponding rating.
x, y = ml1m.load_data()

x_train, x_test, y_train, y_test = train_test_split(
    x, y, test_size=0.2, random_state=0)

config = Config()
config.num_users = np.max(x[:, 0]) + 1
config.num_items = np.max(x[:, 1]) + 1
config.min_value = np.min(y)
config.max_value = np.max(y)

with tf.Session() as sess:
    # For SVD++ algorithm, if `dual` is True, then the dual term of items' 
    # implicit feedback will be added into the original SVD++ algorithm.
    # model = SVDPP(config, sess, dual=False)
    # model = SVDPP(config, sess, dual=True)
    model = SVD(config, sess)
    model.train(x_train, y_train, validation_data=(
        x_test, y_test), epochs=20, batch_size=1024)
        
    y_pred = model.predict(x_test)
    print('rmse: {}, mae: {}'.format(rmse(y_test, y_pred), mae(y_test, y_pred)))
        
    # Save model
    model = model.save_model('model/')
    
    # Load model
    # model = model.load_model('model/')

Performance

The experiments are set up on MovieLens 100K and MovieLens 1M. The results reported here are evaluated on 5-folds cross validation with random seed 0 and taken average of them. All models use default configuration. For MovieLens 100K, the batch size is 128. As for MovieLens 1M, a quite larger dataset, the batch size is 1024. With GPU acceleration, both SVD and SVD++ speed up significantly compared with Surprise, which is the implementation based on cPython. The following is the performance on GTX 1080:

MovieLens 100K

RMSE MAE Time (sec/epoch)
SVD 0.91572 0.71964 < 1
SVD++ 0.90484 0.70982 4
Dual SVD++ 0.89334 0.70020 7

MovieLens 1M

RMSE MAE Time (sec/epoch)
SVD 0.85524 0.66922 4
SVD++ 0.84846 0.66306 40
Dual SVD++ 0.83672 0.65256 50

Some similar experiments can be found at MyMediaLite, Surprise and LibRec.

References

Tensorflow

MyMediaLite

Surprise

LibRec

Also see my ML2017 repo, there is a Keras implementation for SVD and SVD++ in hw6.

Contact

Issues and pull requests are welcomed. Feel free to contact me if there's any problems.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].