Loading the entire dataset into the memory
The first step in building a nonnegative factorization model is to load the entire dataset in the memory. For this task, we will be leveraging NumPy highly.
Getting ready
In order to complete this recipe, you'll have to download the MovieLens database from the University of Minnesota's GroupLens page at
http://grouplens.org/datasets/movielens/
and unzip it in a working directory where your code will be. We will also use NumPy in this code significantly, so please ensure that you have this numerical analysis package downloaded and ready. Additionally, we will use the load_reviews
function from the previous recipes. If you have not had the opportunity to review the appropriate section, please have the code for that function ready.
How to do it...
To build our matrix factorization model, we'll need to create a wrapper for the predictor that loads the entire dataset into memory. We will perform the following steps:
- We create the following
Recommender
class...