# Recommendation Systems: Generating Basic Recommendations

*This is part 2 of our series on Recommendation Systems**, previous segments are available in our archives.*

Most people think about Netflix when they think about recommendations. The more movies I watch and indicate I enjoy, the better Netflix can suggest other movies for me. This is the most basic form of recommendation system as it is acting on a simple matrix of customers and products, as you might see below:

For each product, there are a series of ratings given to it by some set of customers. Not all customers will rate every product, so the matrix is sparse (the NA’s noted above). A basic recommendation system’s goal is to fill in those gaps with estimates about what a customer would rate a given product, given their other ratings. The end result is a mix of real and estimated ratings like you see below:

With those estimated ratings in hand, it is simple to recommend new products to customers by simply selecting the products with the highest estimated ratings!

How do we come up with those estimates? There are a variety of approaches [1], but the most powerful strategy is known as matrix factorization. The goal with this approach is to find two matrices, P and Q, which multiply together to create a close approximation of the known recommendation matrix, denoted M.

You start by randomly generating P and Q, which would multiply together and create something completely unlike the target matrix of known recommendations, M. Using an approach like Gradient Descent, you iteratively improve on P and Q so that they approach M. A side effect of this convergence are estimates of the missing cells of the recommendation matrix – our missing ratings. [2]

This approach is great if all you have are a single rating for each product by some customers. But what if you know more about those customers and those products? Can you do better? Perhaps, and we’ll cover one way to do so tomorrow.

[1] If you’d like to read about the variety of approaches used in solving the Netflix problem there is a great summary here.

[2] If you’d like to see the raw math and an example implementation in Python, there is a great and detailed example here.

Quote of the Day: *“…the additional accuracy gains that we measured did not seem to justify the engineering effort needed to bring them into a production environment.” – **Netflix** on why they did not use the algorithm that won the **Netflix Prize** for best recommendation system.*