Skip to content

Instantly share code, notes, and snippets.

@jfkirk
Last active January 19, 2019 20:35
Show Gist options
  • Save jfkirk/2a91b91e66c557124a28b79fd211e3e5 to your computer and use it in GitHub Desktop.
Save jfkirk/2a91b91e66c557124a28b79fd211e3e5 to your computer and use it in GitHub Desktop.
# Try concatenating the genres on to the indicator features for a hybrid recommender system
full_item_features = sparse.hstack([item_indicator_features, movie_genre_features])
print("Training hybrid recommender")
hybrid_model = tensorrec.TensorRec(
n_components=5,
loss_graph=tensorrec.loss_graphs.WMRBLossGraph()
)
hybrid_model.fit(interactions=sparse_train_ratings_4plus,
user_features=user_indicator_features,
item_features=full_item_features,
n_sampled_items=int(n_items * .01))
print("Hybrid recommender:")
predicted_ranks = hybrid_model.predict_rank(user_features=user_indicator_features,
item_features=full_item_features)
check_results(predicted_ranks)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment