Maher Malaeb
Jul 30, 2017 · 1 min read

Hi,

Your answers can be found in the FAQ section of the Surprise library documentation. Those functionalities aren’t supported natively yet but there is a clear suggestion on how to get them.

For your first question on how to recommend items to users you can do the following.

  1. Define the get_top_n() as defined here
  2. Run the following on a trainset
# Than predict ratings for all pairs (u, i) that are NOT in the training set.
testset = trainset.build_anti_testset()
predictions = algo.test(tests)

3. Get the top 10 items for each top_n_dict=get_top_n(predictions, n=10) which returns a dictionary with uid as keys and top-N predictions as values. So getting top predictions for a user with internal raw ID 1234 should be something like top_n_dict[1234]

Concerning your second question about the most similar user I suggest you check the part of the FAQ here but this is specific to algorithms that uses similarity measures such as K-NN and not all algorithm. To my knowledge there is not general function to get similar users so far in Surprise. But keep an eye because it is being enhanced periodically.

Maher Malaeb
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade