-
Notifications
You must be signed in to change notification settings - Fork 220
Home
TensorRec is a Python recommendation system that allows you to quickly develop recommendation algorithms and customize them using TensorFlow.
TensorRec lets you to customize your recommendation system's embedding functions and loss functions while TensorRec handles the data manipulation, scoring, and ranking to generate recommendations.
A TensorRec system consumes three pieces of data: user_features
, item_features
, and interactions
. It uses this data to learn to make and rank recommendations.
For more information, and for an outline of this project, please read this blog post.
TensorRec can be installed via pip:
pip install tensorrec
import numpy as np
import tensorrec
# Build the model with default parameters
model = tensorrec.TensorRec()
# Generate some dummy data
interactions, user_features, item_features = tensorrec.util.generate_dummy_data(num_users=100,
num_items=150,
interaction_density=.05)
# Fit the model for 5 epochs
model.fit(interactions, user_features, item_features, epochs=5, verbose=True)
# Predict scores for all users and all items
predictions = model.predict(user_features=user_features,
item_features=item_features)
# Calculate and print the recall at 10
r_at_k = tensorrec.eval.recall_at_k(model, interactions,
k=10,
user_features=user_features,
item_features=item_features)
print(np.mean(r_at_k))
The following examples show what user/item features and interactions would look like in a TensorRec system meant to recommend business consulting projects (items) to consultants (users).
The data is represented in matrices. TensorRec can consume these matrices as any scipy.sparse
matrix.
Images from Medium