Recommender systems are one of the most commonly used practical systems in data science. In this section, we will focus on collaborative filtering, where the focus is on similarities between users. Depending on the past preference of users, this type of recommender system recommends items that users have liked or rated highly in the past. For this task, we will use Surprise, a Python scikit-learn library for building and analyzing recommender systems.
We first need to read the merged df into Surprise, set the rating scale of the dataset, and load data from df into Surprise data:
# Set rating scale of the dataset
reader = Reader(rating_scale=(0, 2))
# Load the dataframe with ratings.
data = Dataset.load_from_df(df[['userID', 'placeID', 'rating']], reader)
Now, we are set and can use the Surprise library functionalities. First, we will...