# How to predict for test set when training a recommender by decomposing the utility matrix X=UV?

This probably sounds stupid but I don't get the workflow of building a recommending system by the utility matrix: X[i,j] = how much the ith user likes the jth object. For practical issues I refer to the blog of Simon Funk. Suppose X, created from the training set only, is a sparse matrix whose entries are mostly unknown/missing. By some approach we manage to find U and V that minimize the difference between the known entries of X and the corresponding entries of UV. Now it's time to predict for the test set.

• If a pair of (user,object) has been included in the unknown entries of X, should we trust the value at the same location of UV? I thought this is the whole point of utility matrix and SVD until Simon wrote a lot about "SVD algorithm tends to make a mess of sparsely observed movies or users", then I'm lost.

20 million free parameters is still rather a lot for a training set with only 100 million examples. While it seems like a neat idea to just ignore all those blank spaces in the implicit ratings matrix, the truth is we have some expectations about what's in them, and we can use that to our advantage. As-is, this modified SVD algorithm tends to make a mess of sparsely observed movies or users. To give an example, imagine you have a user who has only rated one movie, say American Beauty. Let's say they give it a 2 while the average is (just making something up) 4.5, and further that their offset is only -1, so we would, prior to even employing the SVD, expect them to rate it 3.5. So the error given to the SVD is -1.5 (the true rating is 1.5 less than we expect). Now imagine that the current movie-side feature, based on broader context, is training up to measure the amount of Action, and let's say that's a paltry 0.01 for American Beauty (meaning it's just slightly more than average). The SVD, recall, is trying to optimize our predictions, which it can do by eventually setting our user's preference for Action to a huge -150.0. I.e., the algorithm naively looks at the one and only example it has of this user's preferences, in the context of the one and only feature it knows about so far (Action), and determines that our user so hates action movies that even the tiniest bit of action in American Beauty makes it suck a lot more than it otherwise might. This is not a problem for users we have lots of observations for because those random apparent correlations average out and the true trends dominate.

• If the user has been included in the training set but the object has not (or the other way around), do we predict with the average score given by the user in the training set? Or is the BetterMean in Simon's blog required? And more importantly, should we use X or UV to compute the (naive or blended) average?

However, even this isn't quite as simple as it appears. You would think the average rating for a movie would just be... its average rating! Alas, Occam's razor was a little rusty that day. Trouble is, to use an extreme example, what if there's a movie which only appears in the training set once, say with a rating of 1. Does it have an average rating of 1? Probably not! In fact you can view that single observation as a draw from a true probability distribution who's average you want... and you can view that true average itself as having been drawn from a probability distribution of averages--the histogram of average movie ratings essentially. If we assume both distributions are Gaussian, then according to my shoddy math the actual best-guess mean should be a linear blend between the observed mean and the apriori mean, with a blending ratio equal to the ratio of variances. That is: If Ra and Va are the mean and variance (squared standard deviation) of all of the movies' average ratings (which defines your prior expectation for a new movie's average rating before you've observed any actual ratings) and Vb is the average variance of individual movie ratings (which tells you how indicative each new observation is of the true mean--e.g,. if the average variance is low, then ratings tend to be near the movie's true mean, whereas if the average variance is high, then ratings tend to be more random and less indicative), then:

BogusMean = sum(ObservedRatings)/count(ObservedRatings)

K = Vb/Va

BetterMean = [GlobalAverage*K + sum(ObservedRatings)] / [K + count(ObservedRatings)]

• I have same problem with building a recommender when using UV decompostion. But there are any way can help ur to do that. Please read "infolab.stanford.edu/~ullman/mmds/ch9.pdf " and Matrix and Tensor Factorization Techniques for Recommender Systems – Tài Hoàng Dec 9 '20 at 14:22
• @TàiHoàng Thank you! We used this textbook as well. However I'm still confused about what to do when a movie/user in test set is unseen in training set. – Paw in Data Dec 10 '20 at 15:56