Created
January 18, 2019 16:41
-
-
Save jfkirk/05c52ed879e72965e4d435a71b7bf085 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fit a content-based model using the genres as item features | |
print("Training content-based recommender") | |
content_model = tensorrec.TensorRec( | |
n_components=n_genres, | |
item_repr_graph=tensorrec.representation_graphs.FeaturePassThroughRepresentationGraph(), | |
loss_graph=tensorrec.loss_graphs.WMRBLossGraph() | |
) | |
content_model.fit(interactions=sparse_train_ratings_4plus, | |
user_features=user_indicator_features, | |
item_features=movie_genre_features, | |
n_sampled_items=int(n_items * .01)) | |
# Check the results of the content-based model | |
print("Content-based recommender:") | |
predicted_ranks = content_model.predict_rank(user_features=user_indicator_features, | |
item_features=movie_genre_features) | |
check_results(predicted_ranks) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment