Collaborative Filtering in a Non-Uniform World: Learning with the Weighted Trace Norm

Ruslan Salakhutdinov, Nathan Srebro

Introduction

Trace-norm regularization is a popular approach for matrix completion and collaborative filtering, motivated both as a convex surrogate to the rank Fazel et al. (2001); Candes & Tao (2009) and in terms of a regularized infinite factor model with connections to large-margin norm-regularized learning Srebro et al. (2005b); Bach (2008); Abernethy et al. (2009); Salakhutdinov & Mnih (2008).

Current theoretical guarantees on using the trace-norm for matrix completion all assume a uniform sampling distribution over entries of the matrix Srebro & Shraibman (2005); Candes & Tao (2009); Candes & Recht (2009); Candes & Tao (2009); Recht (2009). In a collaborative filtering setting, where rows of the matrix represent e.g. users and columns represent e.g. movies, this corresponds to assuming all users are equally likely to rate movies and all movies are equally likely to be rated. This of course cannot be further from the truth, as in any actual collaborative filtering application, some users are much more active then others and some movies are rated by many people while others are much less likely to be rated.

In Section 4 we suggest a correction to the trace-norm regularizer, which we call the weighted trace-norm, that takes into account the sampling distribution. This correction is motivated by our analytic analysis and we discuss how it corrects the problems that the unweighted trace-norm has with non-uniform sampling. We then show how the weighted trace-norm indeed yields a significant improvement on the (highly non-uniformly sampled) Netflix dataset.

Complexity Control in terms of Matrix Factorizations

where YSY_{S}, and similarly XSX_{S}, denotes the matrix “masked” by SS:

For now we ignore possible repeated entries in SS. We will also assume that n≤mn\leq m without loss of generality.

The two formulations (1) and (2) are equivalent up to some (unknown) correspondence between λ\lambda and CC, and we will be referring to them interchangeably at our convenience.

Directly constraining the rank of XX forms one of the most popular approaches to collaborative filtering. Training such a model amounts to finding the best rank-kk approximation to the observed target matrix YY under the given loss function. However, the rank is non-convex and hard to minimize. It is also not clear if a strict dimensionality constraint is most appropriate for measuring the complexity.

2 Trace-norm Regularization

Lately, methods regularizing the norm of the factorization U⊤VU^{\top}V, rather then its dimensionality, have been advocated and were shown to enjoy considerable empirical success Rennie & Srebro (2005); Salakhutdinov & Mnih (2008). This is captured by measuring complexity in terms of the trace-norm of XX, which can be defined equivalently either as the sum of the singular values of XX, or as Fazel et al. (2001):

Note that the dimensionality of UU and VV in (4) is not constrained. Beyond the modeling appeal of norm-based, rather then dimension-based, regularization, the trace-norm is a convex function of XX and so can be minimized by either local search or more sophisticated convex optimization techniques.

3 Scaling of the Trace-norm

It will be useful for us to consider the scaling of the trace-norm with the size of the matrix XX. This will allow us, for example, to understand the magnitude of the bound CC we can expect to put on the trace-norm in the formulation (2).

The rank, as a measure of complexity, does not scale with the size of the matrix. That is, even very large matrices can have low rank. Viewing the rank as a complexity measure corresponding to the number of underlying factors, if data is explained by e.g. two factors, then no matter how many rows (“users”) and columns (“movies”) we consider, the data will still have rank two.

where in the second inequality we used the fact that the number of non-zero singular values is equal to the rank. The Frobenius norm certainly increases with the size of the matrix, since the magnitude of each element does not decrease when we have more elements, and so the trace-norm will also increase. The above suggests measuring the trace-norm relative to the Frobenius norm. Without loss of generality, consider each target entry to be of roughly unit magnitudeAny other constant magnitude will only result in some constant scaling, e.g. ±1\pm 1, and so in order to fit YY each entry of XX must also be of roughly unit magnitude. This suggests scaling the trace-norm by nm\sqrt{nm}. More specifically, we study the trace-norm through the complexity measure:

which puts the trace-norm on a comparable scale to the rank. In particular, when each entry of XX is, on-average, of unit magnitude (i.e. has unit variance), in which case ∥X∥F=nm\left\lVert{X}\right\rVert_{\text{F}}=\sqrt{nm}, we have:

Another place where we can see that tc(X)\textit{tc}(X) plays a similar role to rank(X)\textit{rank}(X) is in the generalization and sample complexity guarantees that can be obtained for low-rank and low-trace-norm learning. Such learning guarantees were mostly discussed in the context of Lipschitz continuous loss functions (i.e. functions with a bounded first derivative), rather then the squared loss. The squared loss has a bounded second derivative rather then bounded first derivative and so requires somewhat different technical tools. Nevertheless, the main thrust of the results is still valid.

Without getting into the technical tools required to rigorously establish the above sample complexity guarantees, it is useful to understand them at a more abstract level. In order to understand the guarantees for low-rank learning, it is enough to consider the number of parameters in the rank-kk factorization X=U⊤VX=U^{\top}V. It is easy to see that the number of parameters in the factorization is roughly k(m+n)k(m+n) (perhaps a bit less due to rotational invariants). And so we would expect to be able to learn XX when we have roughly this many samples, as is indeed confirmed by the rigorous sample complexity bounds.

For low-trace-norm learning, consider a sample SS of size ∣S∣≤Cn|S|\leq Cn, for some constant CC. Taking entries of YY to be of unit magnitude, we have ∥YS∥F=∣S∣=Cn\left\lVert{Y_{S}}\right\rVert_{\text{F}}=\sqrt{|S|}=\sqrt{Cn} (Recall that YSY_{S} is defined to be zero outside SS). From (5) we therefore have: ∥YS∥tr≤Cn⋅n=Cn\left\lVert{Y_{S}}\right\rVert_{\text{tr}}\leq\sqrt{Cn}\cdot\sqrt{n}=\sqrt{C}n and so tc(YS)≤C\textit{tc}(Y_{S})\leq C. That is, we can “shatter” any sample of size ∣S∣≤Cn|S|\leq Cn with tc(X)=C\textit{tc}(X)=C: no matter what the underlying matrix YY is, we can always perfectly fit the training data with a low trace-norm matrix XX s.t. tc(X)≤C\textit{tc}(X)\leq C, without generalizing at all outside SS. On the other hand, we must allow matrices with tc(X)=tc(X∗)\textit{tc}(X)=\textit{tc}(X^{*}), otherwise we can’t hope to find X∗{\cal{X}}^{*}, and so we can only constrain tc(X)≤C=tc(X∗)\textit{tc}(X)\leq C=\textit{tc}(X^{*}). We therefore cannot expect to learn with less then ntc(X∗)n\textit{tc}(X^{*}) samples. It turns out that this is essentially the largest random sample that can be shattered with tc(X)≤C=tc(X∗)tc(X)\leq C=\textit{tc}(X^{*}), and that if we have more then this many samples we can start learning. For our purposes here, we will mostly just make use of non-learnability arguments of this form: if we can shatter a random sample of size ∣S∣|S| with a matrix XX have the same complexity (e.g. trace-norm) as our target matrix X∗X^{*}, we cannot hope to learn without a larger sample.

Trace-Norm Under a Non-Uniform Distribution

In this section, we will analyze trace-norm regularized learning when the sampling distribution is not uniform. That is, when there is some, known or unknown, non-uniform distribution D{\cal{D}} over entries of the matrix YY (i.e. over index pairs (i,j)(i,j)) and our sample SS is sampled i.i.d. from D{\cal{D}}. Of course, if D{\cal{D}} concentrates on only a small subset of the matrix, we have no hope of recovering rows and columns of YY on which we have zero probability of seeing an observation. Instead, our objective here, as is typically the case in learning under an arbitrary distribution, is to get low average error with respect to the same distribution D{\cal{D}}. That is, we measure generalization performance in terms of the weighted sum-squared-error:

However, the same does not hold when learning using the trace-norm. To see this, consider an orthogonal rank-kk square n×nn\times n matrix, and a sampling distribution which is uniform over an nA×nAn_{A}\times n_{A} sub-matrix AA, with nA=nan_{A}=n^{a} (see Fig. 1). That is, the row (e.g. “user”) is selected uniformly among the first nAn_{A} rows, and the column (e.g. “movie”) is selected uniformly among the first nAn_{A} columns. We will use AA to denote the subset of entries in the submatrix, i.e. A={(i,j)∣1≤i,j≤nA}A=\{(i,j)|1\leq i,j\leq n_{A}\}, rather then the matrix itself, and so we can say that D{\cal{D}} is uniform on AA. For any sample SS, we have:

where we again take the entries in YY to be of unit magnitude. In the second inequality above we use the fact that YSY_{S} is zero outside of AA, and so we can bound the rank of YSY_{S} by the dimensionality nA=nan_{A}=n^{a} of AA.

To do so, consider another submatrix BB of size nB×nBn_{B}\times n_{B} with nB=n/2n_{B}=n/2, such that the rows and columns of AA and of BB do not overlap (Fig. 1). Now, consider a sampling distribution D{\cal{D}} which is uniform over AA with probability half, and uniform over BB with probability half. Consider fitting a noisy matrix Y=X∗+noiseY=X^{*}+\text{noise} where X∗X^{*} is “orthogonal” rank-kk. In order to fit on BB, we need to allow a trace-norm of at least ∥XB∗∥tr=n2k\left\lVert{X^{*}_{B}}\right\rVert_{\text{tr}}=\frac{n}{2}\sqrt{k}, i.e. allow tc(X)=k/4\textit{tc}(X)=k/4. But as discussed above, with such a generous constraint on the trace-norm, we will be able to shatter S⊂AS\subset A whenever ∣S∩A∣=∣S∣/2≤k/4n2−a|S\cap A|=|S|/2\leq k/4n^{2-a}. Since there is no overlap in rows and columns, and so values in the sub-matrices AA and BB are independent, shattering S∩AS\cap A means we cannot hope to learn in AA. Setting a=2/3a=2/3 as before, it seems that with o(n4/3)o(n^{4/3}) samples, we cannot learn in both AA and BB: either we constrain to a trace-norm which is too low to fit XB∗X^{*}_{B} (we under-fit on BB), or we allow a trace-norm which is high enough to overfit YS∩AY_{S\cap A}. Either way, we will make errors on at least half the mass of D{\cal{D}}.To make the above argument more precise, we should note that if we do allow high enough trace-norm to fit BB, and ∣S∣=o(n4/3)|S|=o(n^{4/3}), then the “cost” of overfitting YS∩AY_{S\cap A} is negligible compared to the cost of fitting XB∗X^{*}_{B}. For large enough nn, we would be tempted to very slightly deteriorate the fit of XB∗X^{*}_{B} in order to “free up” enough trace-norm and completely overfit YS∩AY_{S\cap A}.

Figure 2, left panel, precisely illustrates this phenomenon on a simulation experiment. For this synthetic example, we used nA=300n_{A}=300 and nB=4700n_{B}=4700, with an orthogonal rank-2 matrix X∗X^{*} and Y=X∗+N(0,1)Y=X^{*}+{\cal{N}}(0,1) (in case of repeated entries, the noise is independent for each appearance in the sample). The training sample size was also set to ∣S∣|S|=140,000.

The three curves of Fig. 2 measure the excess (test) error ∥X−X∗∥D2=∥X−Y∥D2−∥Y−X∗∥D2\left\lVert{X-X^{*}}\right\rVert_{{\cal{D}}}^{2}=\left\lVert{X-Y}\right\rVert_{{\cal{D}}}^{2}-\left\lVert{Y-X^{*}}\right\rVert_{{\cal{D}}}^{2} of the learned model, as well as the error contribution from AA and from BB, as a function of the constraint on tc(X)\textit{tc}(X), for the sampling distribution discussed above and a specific sample size. As can be seen, although it is possible to constrain tc(X)\textit{tc}(X) so as to achieve squared-error of less then 0.80.8 on BB, this constraint is too lax for AA and allows for over-fitting. Constraining tc(X)\textit{tc}(X) so as to avoid overfitting AA (achieving almost zero excess test error), leads to a suboptimal fit on BB.

Until now we discussed learning by constraining the trace-norm, i.e. using the formulation (2). It is also insightful to consider the penalty view (1), i.e. learning by minimizing

First observe that the characterization (4) allows us to decompose ∥X∥tr=∥XA∥tr+∥XB∥tr\left\lVert{X}\right\rVert_{\text{tr}}=\left\lVert{X_{A}}\right\rVert_{\text{tr}}+\left\lVert{X_{B}}\right\rVert_{\text{tr}}, where w.l.o.g. we take all columns of UU and VV outside AA and BB to be zero. Since we also have ∥YS−XS∥F2=∥YA∩S−XA∩S∥F2+∥YB∩S−XB∩S∥F2\left\lVert{Y_{S}-X_{S}}\right\rVert_{\text{F}}^{2}=\left\lVert{Y_{A\cap S}-X_{A\cap S}}\right\rVert_{\text{F}}^{2}+\left\lVert{Y_{B\cap S}-X_{B\cap S}}\right\rVert_{\text{F}}^{2}, we can decompose the training objective (10) as:

Returning to our simulation experiment, the solid curves of Fig. 3 show the excess test error for the minimizer of the training objective (11), as a function of the regularization tradeoff parameter λ\lambda. Note that these are essentially the same curves as displayed in Fig. 2, except the path of regularized solutions is now parameterized by λ\lambda rather then by the bound on tc(X)\textit{tc}(X). Not surprisingly we see the same phenomena: different values of λ\lambda are required for optimal learning on AA and on BB. Forcing the same λ\lambda on both parts of the training objective (11) yields a deterioration in the generalization performance.

Weighted Trace Norm

The decomposition (11) and the discussion in the previous section suggests weighting the trace-norm by the frequency of rows and columns. For a sampling distribution D{\cal{D}}, denote by p(i)p(i) the row marginal, i.e. the probability of observing row ii, and similarly denote by q(j)q(j) the column marginal. We propose using the weighted version of the trace-norm as a regularizer:

where diag(p)\textrm{diag}(\sqrt{p}) is a diagonal matrix with p(i)\sqrt{p(i)} on its diagonal (similarly diag(q)\textrm{diag}(\sqrt{q})). The corresponding normalized complexity measure is given by tcp,q(X)=∥X∥tr(p,q)2\textit{tc}_{p,q}(X)=\left\lVert{X}\right\rVert_{\text{tr}\left(p,q\right)}^{2}. Note that for a uniform distribution we have that tcp,q(X)=tc(X)\textit{tc}_{p,q}(X)=\textit{tc}(X). Furthermore, it is easy to verify that for an “orthogonal” rank-kk matrix XX we have tcp,q(X)=k\textit{tc}_{p,q}(X)=k for any sampling distribution.

Returning to the penalization view (2) we can again decompose the training objective:

avoiding the scaling by the block sizes which we encountered in (11).

Returning to the synthetic experiments of Fig. 3, and comparing (11) with (14), we see that introducing the weighting corresponds to a relative change of nA/nBn_{A}/n_{B} in the correspondence of the regularization tradeoff parameters used for AA and for BB. This corresponds to a shift of log⁡nAnB\log\frac{n_{A}}{n_{B}} in the log-domain used in the figure. Shifting the solid red (bottom) curve by this amount yields the dashed red (bottom) curve. The solid blue (top) curve and the dashed red (bottom) curve thus represent the excess error on BB and on AA when the weighted trace norm is used, i.e. the training objective (14) is minimized (except for an overall scaling in λ\lambda). The dashed black (middle) curve is the overall excess error when using this training objective. As can be seen, the weighting aligns the excess errors on AA and on BB much better, and yields a lower overall error. The weighted trace-norm achieves the lowest MSE of 0.4301 with corresponding λ=0.11\lambda=0.11. This is compared to the lowest MSE of 0.4981 with λ=0.80\lambda=0.80, achieved by the unweighted trace-norm. It is also interesting to observe that the weighted trace-norm outperforms its unweighted counterpart for a wide range of regularization parameters λ∈[0.01;0.6]\lambda\in[0.01;0.6]. This may also suggest that in practice, particularly when working with large and imbalanced datasets, it may be easier to search for regularization parameters using weighted trace-norm. Fig. 2, right panel, further shows the test error as a function on the constraint tcp,q(X)\textit{tc}_{p,q}(X).

Finally, Fig. 3 also suggests that the optimal shift is actually smaller then nA/nBn_{A}/n_{B}. We consider a smaller shift by using the partially-weighted trace-norm:

And he corresponding normalized complexity measure tcp,q,α(X)=∥X∥tr(pαn1−α,qαm1−α)2\textit{tc}_{p,q,\alpha}(X)=\left\lVert{X}\right\rVert_{\text{tr}\left(\frac{p^{\alpha}}{n^{1-\alpha}},\frac{q^{\alpha}}{m^{1-\alpha}}\right)}^{2}.

Practical Implementation

When dealing with large datasets, such as the Netflix data, the most practical way to fit trace-norm regularized models is through stochastic gradient descent Salakhutdinov & Mnih (2008); Koren (2008).

Let ni=∑jSijn_{i}=\sum_{j}S_{ij} and mj=∑iSijm_{j}=\sum_{i}S_{ij} denote the number of observed ratings for user ii and movie jj respectively. The training objective (over the index pairs (i,j)(i,j)) using partially-weighted trace-norm (Eq. 4) can be written as:

Note that even though the objective (16) as a function of UU and VV is non-convex, there are no non-global local minima if we set kk to be large enough, i.e. k>min⁡(n,m)k>\min(n,m) Burer & Monteiro (2005). However, fitting orthogonal models in practice with very large values of kk becomes computationally expensive. Instead, we consider truncated trace-norm minimization by restricting kk to smaller values. In the next section we demonstrate that even when using truncated trace-norm, its weighted version significantly improves model’s prediction performance.

In all of our experiments, we also replace unknown row p(i)p(i) and column q(j)q(j) marginals in \eqrefeq:sgd\eqref{eq:sgd} by their empirical estimates p^(i)=\nicefracni∣S∣\hat{p}(i)=\nicefrac{{n_{i}}}{{|S|}} and q^(j)=\nicefracmj∣S∣\hat{q}(j)=\nicefrac{{m_{j}}}{{|S|}}. This results in the following objective:

Setting α=1\alpha=1, corresponding to the weighted trace-norm (4), results in stochastic gradient updates that do not involve the row and column counts at all and are in some sense the simplest. Strangely, and likely originating as a “bug” in calculating the stochastic gradients by one of the participants, these are the actual SGD steps used by many practitioners on the Netflix dataset Koren (2008); Takács et al. (2009); Salakhutdinov & Mnih (2008).

Experimental results

We evaluated various models on the Netflix dataset, which is the largest publicly available collaborative filtering dataset. The training set contains 100,480,507 ratings from 480,189 randomly-chosen, anonymous users on 17,770 movie titles. As part of the training data, Netflix also provides qualification set, containing 1,408,395 ratings. The pairs were selected from the most recent ratings for a subset of the users in the training dataset. Due to the special selection scheme, ratings from users with few ratings are overrepresented in the qualification set, relative to the training set. To avoid the issue of dealing with different training and test distributions, we also created our own validation and test sets, each containing 100,000 ratings that were randomly selected from the training set. As a baseline, Netflix provided the test score of its own system trained on the same data, which is 0.9514.

This dataset is interesting for several reasons. First, it is very large, and very sparse (98.8% sparse). Second, the dataset is very imbalanced with highly non-uniform samples. It includes users with over 10,000 ratings as well as users who rated fewer than 5 movies.

In our first experiment, for various values of α\alpha, we fit parameters UU and VV using stochastic gradient descent as in (17) with k=30k=30. Both UU and VV were randomly initialized for all models and regularization parameters λ\lambda were chosen by cross-validation.

Performance results of the weighted trace-norm regularization for various values of α\alpha are shown in table 1. Observe that that the weighted trace-norm (α=1\alpha=1) achieved a RMSE of 0.9105 on the Netflix qualification set, significantly outperforming its unweighted counterpart with α=0\alpha=0, that achieved a RMSE of 0.9235. This large performance gap is striking. It clearly suggests that the weighting is quite important. Table 1 further reveals that the weighted trace-norm (α=1\alpha=1) is not optimal. Surprisingly, partially weighted trace-norm with α=0.9\alpha=0.9 achieved a RMSE of 0.9091, slightly outperforming the weighted matrix factorization. Performance results on the artificially created test set are similar to the results on the qualification set. Note also that the large gap in generalization performance between the test and the qualification sets is due to the Netflix’s special qualification selection scheme.

In our second experiment, we fitted much larger models with k=100k=100. As expected, the weighted trace-norm regularization (α=1\alpha=1) attained a RMSE 0.9071, significantly improving upon the unweighted model’s RMSE of 0.9203. Again, this large performance gap strongly suggests that the weighting can yield significant performance boost, particularly when dealing with very imbalanced data, such as the Netflix dataset.

In all of our experiments, we also empirically observed that for a wide range of regularization parameters λ\lambda, optimizing the weighted trace-norm almost always yielded better predictions on both the test and the Netflix qualification sets than optimizing the unweighted trace-norm. This confirms our previous results on the synthetic experiment and strongly suggests that it may be far easier to search for regularization parameters using the weighted trace-norm.

Discussion

In this paper we showed both analytically and empirically that under non-uniform sampling, trace-norm regularization can lead to significant performance deterioration and an increase in sample complexity. Motivated by our analytic analysis, we further suggested a corrected version of the trace-norm, called weighted trace-norm, that does take into account the non-uniform sampling distribution. Our results on both synthetic and highly imbalanced Netflix datasets further demonstrate that the weighted trace-norm yields significant improvements in prediction quality. It is interesting to note that setting α=1\alpha=1 in the weighted trace-norm objective (4) implies that the frequent users (movies) get regularized much stronger than the rare users (movies). From Bayesian perspective, such regularization is quite unusual, since it effectively states that the effect of the prior becomes stronger as we observe more data. Yet, our analysis and empirical results strongly suggest that in non-uniform setting, such “unorthodox” regularization is crucial for achieving good generalization performance.

Although theoretical guarantees are not the focus of this work, we hope that the weighted trace-norm, and the discussions in Sections 3 and 4, will be helpful in deriving theoretical learning guarantees for non-uniform sampling distributions, both in the form of generalization error bounds as in Srebro & Shraibman (2005), and generalizing the compressed-sensing inspired work on recovery of noisy low-rank matrices as in Candes & Plan (2009); Recht (2009).

R.S. acknowledges the financial support from NSERC, Shell, and NTT Communication Sciences Laboratory.

References