Get startedGet started for free

Do recommendations make sense

Now that we have an understanding of how well our model performed, and have some confidence that it will provide recommendations that are relevant to users, let's actually look at recommendations made to a user and see if they make sense.

The original ratings data is provided here as original_ratings. Take a look at user 60 and user 63's original ratings, and compare them to what ALS recommended for them. In your opinion, are the recommendations consistent with their original preferences?

This exercise is part of the course

Building Recommendation Engines with PySpark

View Course

Exercise instructions

  • Use the .filter() on the original_ratings dataframe to ensure that col("userId") equals 60 to look at user 60's original ratings. Call the .sort() method to sort the output by rating and set the ascending argument to False to see the highest ratings first.
  • Use the .filter() and .show() methods on the recommendations dataset to look at user 60's ratings. Note that when ALS generates recommendations, they are provided in descending order by userId, so there's no need to sort the dataframe.
  • Do the same thing for user 63.
  • Do the recommendation genres have some consistency with each user's original ratings?

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Look at user 60's ratings
print("User 60's Ratings:")
original_ratings.filter(col("____") == 60).____("rating", ____ = False).show()

# Look at the movies recommended to user 60
print("User 60s Recommendations:")
____.____(col("userId") == ____).show()

# Look at user 63's ratings
print("User 63's Ratings:")
original_ratings.filter(col("____") == ____).____("rating", ____ = False).show()

# Look at the movies recommended to user 63
print("User 63's Recommendations:")
____.____(col("userId") == ____).show()
Edit and Run Code