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.

Code the recommendation system

Code the recommendation system

From the course: Machine Learning and AI Foundations: Recommendations

Start my 1-month free trial

Code the recommendation system

- [Instructor] Let's write the main code for our recommendation system. Open up factor_review_matrix.py. First, I'll load up the review dataset into a data frame called raw_dataset_df by using pandas read_csv function. Then we use the pandas pivot table function to build the review matrix. At this point, ratings_df contains a sparse array of reviews. Next, we want to factor the array to find the user attributes matrix and the movie attributes matrix that we can multiply back together to recreate the ratings data. To do this, we'll use the low rank matrix factorization algorithm. I've included an implementation of this in matrix_factorization_utilities.py. We'll talk more about how it works in the next video, but let's go ahead and use it. First, we pass in the ratings data, but we'll call pandas as matrix function to make sure we pass then as a numpy matrix data type. Next, this method takes in a parameter called num_features. Num_features controls how many latent features to generate…

Contents