Skip to content

Instantly share code, notes, and snippets.

@jfkirk
Last active January 19, 2019 20:44
Show Gist options
  • Save jfkirk/1e24ae52eb5648e7bca82869939ebee9 to your computer and use it in GitHub Desktop.
Save jfkirk/1e24ae52eb5648e7bca82869939ebee9 to your computer and use it in GitHub Desktop.
# Pull user 432's features out of the user features matrix and predict movie ranks for just that user
u432_features = sparse.csr_matrix(user_indicator_features)[432]
u432_rankings = hybrid_model.predict_rank(user_features=u432_features,
item_features=full_item_features)[0]
# Get internal IDs of User 432's top 10 recommendations
# These are sorted by item ID, not by rank
# This may contain items with which User 432 has already interacted
u432_top_ten_recs = numpy.where(u432_rankings <= 10)[0]
print("User 432 recommendations:")
for m in u432_top_ten_recs:
print(movie_titles_by_internal_id[m])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment