From the course: Machine Learning and AI Foundations: Recommendations

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Represent product reviews as a matrix

Represent product reviews as a matrix

From the course: Machine Learning and AI Foundations: Recommendations

Start my 1-month free trial

Represent product reviews as a matrix

- [Instructor] Our movie review dataset contains one row for each rating. This is the format that reviewed data is typically collected in, but in order to build a recommendations system from this data, we want to create a matrix or two-dimensional array that shows which movies have been rated by which users. The matrix will have one row for each user and one column for each movie. Let's take a look at the code in create_review_matrix.py. First, we're going to use Pandas read_csv function to load the movie_ratings_data_set.csv file. This rating has one row for each individual movie review. To turn this into a matrix that summarizes all reviews across all movies, we need to use Pandas pivot table function. A pivot table takes a list of data and summarizes it with one row and one column for each unique user and unique movie in our dataset. If you have used pivot tables in spreadsheet software like Microsoft Excel, it works exactly the same way here. First we pass in the data frame…

Contents