liveBook · Manning

Matrix factorization

As explained in AI Recommender Systems

Matrix factorization is a technique that decomposes a user-item interaction matrix into lower-dimensional factor matrices representing users and items.

Matrix factorization turns a user–item interaction matrix into two smaller matrices: one of user factors and one of item factors. Each user and item becomes a vector in the same latent space. Their dot product estimates the user’s preference for the item, including items with no recorded rating from that user. section 3.3.1

Figure 3.4 Matrix factorization decomposes the user-item rating matrix (R) into two smaller matrices: user factors (U) and item factors (I). Each user and item is represented by k latent factors (typically 50-200 dimensions). The predicted rating for user u and item i is the dot product of their factor vectors.

The diagram shows the rating matrix decomposed into user and item factors, with a dot product producing each predicted rating. section 3.3.1

Predicting a missing preference

Suppose two users rate Pulp Fiction and Fight Club highly but rate Toy Story poorly, while a third user shows the opposite pattern. Factor vectors can capture those shared preferences, then score movies each user has not rated. In a two-factor illustration, the dot product for one action-film preference is 0.90, while the dot product for Toy Story is −0.18; these are illustrative scores, not ratings on the original scale. section 3.3.1

Alternating Least Squares (ALS) learns the factors by repeatedly holding item vectors fixed while optimizing user vectors, then holding user vectors fixed while optimizing item vectors. Each update is a least-squares problem. ALS fits observed interactions rather than treating every missing rating as feedback; its updates can be parallelized for large datasets. Choose factor count, regularization, and iteration count using validation data rather than assuming one setting works everywhere. section 3.3.2 section 3.7

The resulting vectors support both preference prediction and item-to-item similarity, making matrix factorization useful for collaborative-filtering candidate generation. Its limitation is cold start: a new user or item has no interaction history from which to learn a factor vector. Content-based embeddings can supply another retrieval signal, particularly for new items. section 3.3 section 3.7

How AI Recommender Systems covers it

How deep it goes
Works through factor matrices and dot products, then outlines alternating least-squares updates without deriving their closed-form solutions.
Examples
Uses a small movie-rating matrix and two-factor dot products to illustrate observed and missing preferences.
What it assumes
Introduces user–item matrices and dot products through a small example before approaching ALS without neural-network complexity.
What you can do after
Apply it via the implicit library to learn factors with ALS, predict preferences, and find similar items.
How it connects
Links collaborative filtering to embeddings, latent-space similarity, Alternating Least Squares, content-based embeddings, and cold start.

Also explained in

Compare how 3 books explain matrix factorization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Recommender Systems. The section links point to the parts of the book it draws on.