Understand matrix factorization as a way to come up with user attributes.
- [Instructor] Because the ratings matrix is equal to the result of multiplying the user attributes matrix by the movie attributes matrix, we can work backwards using matrix factorization to find values for U and M. In code, we use an algorithm called, low rank matrix factorization, to do this. Let's look at how this algorithm works. Matrix factorization is the idea that a large matrix can be broken down into smaller matrices. So, assuming that we have a large matrix of numbers, and assuming that we want to be able to find two smaller matrices that multiply together to result in that large matrix, our goal is to find two smaller matrices that satisfy that requirement.
If you happen to be an expert in linear algebra, you might know that there are standard ways to factor a matrix, such as using a process called, singular value decomposition. But this is a special case where that won't work. The problem is that we only know some of the values in the large matrix. Many of the entries in the large matrix are blank, or users haven't yet reviewed particular movies. So, instead of trying to directly factor the ratings array into two smaller matrices, we'll estimate values for the smaller matrices using an iterative algorithm. We'll guess and check until we get close to the right answer.
Here's how it works. First, we'll create the U and M matrices, but set all the values to random numbers. Because U and M are full of random numbers, if we multiply U and M right now, the result will be random. The next step is to check how different our calculated ratings matrix is from the real ratings matrix with the current values for U and M. But we'll ignore all the spots in the ratings matrix where we don't have data, and only look at the spots where we have actual user reviews. We'll call this difference the cost. The cost is how wrong we are.
Next, we'll use a numeric optimization algorithm to search for the minimum cost. The numerical optimization algorithm will tweak the numbers in U and M a little at a time. The goal is to get the cost function a little closer to zero at each step. The function we'll use is called fmin_cg. It searches for the inputs that make a function return the minimal possible output. It's provided by the SciPy library. Finally, the fmin_cg function will loop hundreds of times until we get the cost as small as possible. When the value of the cost function is as low as we can get it, the final values of U and M at that point are what we'll use.
But since they're just approximations, they won't be exactly perfect. When we multiply these U and M matrices to calculate movie ratings, and check it against the original movie ratings, we'll see that there's still a bit of difference. But as long as we get pretty close, the small amount of difference won't matter.
Recommendation systems are a key part of almost every modern consumer website. The systems help drive customer interaction and sales by helping customers discover products and services they might not ever find themselves. The course uses the free, open source tools Python 3.5, pandas, and numpy. By the end of the course, you'll be equipped to use machine learning yourself to solve recommendation problems. What you learn can then be directly applied to your own projects.
- Building a machine learning system
- Training a machine learning system
- Refining the accuracy of the machine learning system
- Evaluating the recommendations received