# Matrix Factorization

In Recommender System, **Matrix Factorization** maps both the users and items to a joint latent factor space of dimension , such that the user-item interaction can be modeled as the inner product in this space. That is to say, we map each user to a vector , and each item to a vector . For movie recommendation, each dimension of the latent factor space can be explained as a topic, say comedy v.s. drama, or other features such as amount of action, orientation to children and so on.

Given the latent vector for user and item , we can predict the interaction between them as

The major challenge is to compute the latent vector for each user and item. This is quite similar with **Singular Value Decomposition(SVD)**, a well-established techniques for identifying latent semantic factors in information retrieval. Applying SVD in the collaborative filtering domain requires factoring the user-item rating matrix. This often raises difficulties due to the high portion of missing values caused by the sparseness in the user-item rating matrix. One approach is to rely on imputation to fill in missing ratings to make the matrix dense. However, this will significantly increase the amount of data, and the inaccurate imputation might distort the data.

Matrix Factorization is a method which focus only on the observed ratings only, while avoid overfitting by regularization. Here is the cost function for matrix factorization

Here is the set of pairs for which is known in the training set and is the regularization term.

Several learners have been proposed to optimize Matrix Factorization, including SGD, Coordinate Descent and MCMC.

## Optimization by SGD

SGD loops through all ratings in the training set. For each rating in the training set, let . Then it modifies the parameter in the opposite direction of the gradient yielding:

## Optimization by ALS

Alternating Least Square is a popular approach to optimize regression models such as MF. It works by iteratively optimizing one parameter, while leaving others fixed. The prerequisite of ALS is that the optimization sub-problem can be analytically solved.

First, minimize with respect to user latent vector is equivalent to minimizing:

The minimum is where the first order derivative is 0:

Following the same process, we can get the solution for .

## Adding Biases

The only interpret the rating as an interaction between the user and item , but in the fact, the rating values can also due to effects associated with either users or items. For example, in the recommender system, some user tend to give higher rating than others, or some items is in general better than others. To consider all such effects, we can add a bias term to the

and the corresponding cost function is

## Handle user and item features

Matrix factorization can also handle user and item features beside the rating information. For example, if we also have the implicit feedback such as the purchase or browsing history, as well as some user attributes.

We denote as the sets of items for which user has expressed an implicit feedback, where each item is associated with . So a user who showed a preference for items in is characterized by

Denote as the set of attributes of a user , and a factor vector corresponds to each attribute to describe a user through the set of user-associated attributes:

Then the predicted rating can be modeled by

## Factorization Machines

Although Matrix Factorization can model such kind of implicit feedback and user or item attribute features, **Factorization Machine** can handle such kind of features more directly. For each rating sample with user features(e.g. age, gender, rating history), item features(e.g. genders, price) as well as context features(e.g. time) , we can generate a feature vector for each of these features and then build a factorization machine of degree to model the interactions between them:

where are the model parameters that have to be estimated. A 2-way FM captures all single and pairwise interactions between variables:

- is the global bias.
- models the strength of the i-th variable.
- models the interaction between the i-th and j-th variable.

**Instead of using one model parameter for each interaction, the FM models the interaction by factorizing it. This is the key point which allows high quality parameter estimates of higher-order interactions under sparsity**

As we can see, instead of project the user and item into the latent vector space by matrix factorization, factorization machine project each feature into the latent vector space to better handle various features associated with the user, item and context.

## Field-Aware Factorization Machine

Factorization Machine can effectively model the interaction between user and item, as well as the user side and item side features. But what if there are more than 3 dimension? For example, in the CTR prediction for computational advertising, we may have User, Advertisement as well as Publisher. There is interaction not only between the User and Advertisement, or between User and Publisher, but also interaction among all 3 dimensions. As shown above, the 2-way Factorization Machine can only handle interactions between two features. However, the Field-Aware Factorization Machine can handle all such interactions.

The formulation of FFM is

where

where are respectively the field of and , and and are two vectors with length . Here the field means the dimension, for the recommender system, typically there are 2 dimensions: User and Item. For CTR prediction, there are typically 3 dimensions: User, Advertisement and Publisher. But actually we can build one dimension for each ID features, or even category features.

Here is a concrete example, say there is a sample with 4 features(User, Movie, Gender, Price) and 5 fields(User-Yu, Movie-3I, Gender-Comedy, Gender-Drama, Price).

User(Us) | Movie(Mo) | Gender(Ge) | Price(Pr) |
---|---|---|---|

YuChin(Yu) | 3Idiots(3I) | Comedy, Drama(Co, Dr) | $9.99 |

Then FFM will create 10 vectors, each corresponds to one (field, feature) pair. The in FFM is

FFM has shown very promising results in CTR prediction(KDD CUP 2012, 1st).

# Conclusion

In conclusion, Matrix Factorization projects the user and item into a latent vector space to handle interactions between user and item. Factorization Machine projects each feature into a latent vector space to support interactions between various features associated with user, item and context. At last, Field-aware Factorization Machine projects each feature(field) pair into a latent vector space to handle the interactions between more than 3 dimensions.

# Reference:

- Matrix Factorization Techniques for Recommender System. Y. Koren, et. at.
- Matrix Factorization and Factorization Machine for Recommender Systems. Chih-Jen Lin.
- Factorization Machines. Steffen Rendle.
- 3 Idiots' Approach for Display Advertising Challenge Yu-Chin Juan, Yong Zhuang, and Wei-Sheng Chin.
- Field-aware Factorization Machine Yu-Chin Juan, Yong Zhuang, and Wei-Sheng Chin.
- Pairwise interaction tensor factorization for personalized tag recommendation. Steffen Rendle, Lars Schmidt-Thieme.

Please comment here or send email to pandevirus@gmail for any suggestion.