Currently it has:
- user-user / item-item collaborative filtering
- SVD ( based on scipy's implementation )
- Simon Funk's SVD
- Factorization Machine
- Wide and Deep Network
Install the latest version by running
pip install git+https://github.com/mayukh18/reco.git
Or you can install (old version) from PyPI by running
pip install reco
References:
-
Badrul Sarwar, George Karypis, Joseph Konstan, and John Riedl. Item-Based Collaborative Filtering Recommendation Algorithms, 2001.[pdf]
-
Simon Funk's Blog. Netflix Update: Try This at Home. [link]
-
Arkadiusz Paterek. Improving regularized singular value decomposition for collaborative filtering, 2007. [pdf]
-
Steffen Rendle. Factorization Machines, 2010. [pdf]
-
Heng-Tze Cheng et al. Wide & Deep Learning for Recommender Systems, 2016. [pdf]
FunkSVD
from reco.recommender import FunkSVD
from reco.metrics import rmse
from reco.datasets import loadMovieLens100k
train, test, _, _ = loadMovieLens100k(train_test_split=True)
f = FunkSVD(k=64, learning_rate=0.002, regularizer = 0.05, iterations = 150, method = 'stochastic', bias=True)
# fits the model to the data
f.fit(X=train, formatizer={'user':'userId', 'item':'itemId', 'value':'rating'},verbose=True)
# predicts the ratings from the test set
preds = f.predict(X=test, formatizer={'user':'userId', 'item':'itemId'})
print(rmse(preds, list(test['rating']))
SVDRecommender
from reco.recommender import SVDRecommender
from reco.datasets import loadMovieLens100k
from reco.metrics import rmse
train, test, _, _ = loadMovieLens100k(train_test_split=True)
svd = SVDRecommender(no_of_features=8)
# Creates the user-item matrix, the userIds on the rows and the itemIds on the columns.
user_item_matrix, users, items = svd.create_utility_matrix(train, formatizer={'user':'userId', 'item':'itemId', 'value':'rating'})
# fits the svd model to the matrix data.
svd.fit(user_item_matrix, users, items)
# predict the ratings from test set
preds = svd.predict(test, formatizer = {'user':'userId', 'item': 'itemId'})
print(rmse(preds, list(test['rating'])))
test_users = [1, 65, 444, 321]
# recommends 4 undiscovered items per each user
results = svd.recommend(test_users, N=4)
# outputs 5 most similar users to user with userId 65
similars = svd.topN_similar(x=65, N=5, column='user')
More examples are available here
Partial documentation available here