Skip to content
mlmentorship

Matrix factorization for recsys

Predict missing user-item ratings from shared factors, while separating observed targets, implicit-feedback assumptions, and cold-item support.

Published · 7 min read ·Role-specific ·Intermediate
Reading depth

Summary

A missing rating supplies two indices: a user row and an item row. Matrix factorization shares learned rows across many observed ratings rather than storing an independent prediction per cell. Its low-rank assumption is a modeling choice, not a guarantee of matrix completion.

Let , , and . The shared coordinate count is , and . With zero biases, fixture rows and predict . These are chosen vectors, not a fitted solution for all displayed ratings.

Matching user and item coordinates multiply, then sum to the missing rating

A missing rating is a sum of matched coordinate productsThe example user vector (1,2) and item vector (3,1) predict 1x3+2x1=5. This is a model estimate, not an observed rating.Width: user factor. Height: itemfactor.user factor 1item factor 3area 3user factor 2item factor 1area 23 + 2 = 5Each tile contributes 1Five is a prediction, not an observedrating.
Derivation
One missing entry selects two matching rows, then sums their coordinate productsThe original toy sparse ratings matrix highlights user A and item three. Matching factors u_A=[2,1] and v_3=[1.5,1] contribute three and one, totaling predicted rating four. The complete selection and calculation remain visible in a vertical phone-width composition.Original toy factors; one predicted missingrating1. SELECT user A, item 3 in sparse R1234A53?1B42C15D242. MATCH user and item factor rowsuser Au_A = [2, 1]item 3v_3 = [1.5, 1]factor 12 * 1.5 = 3factor 21 * 1 = 13. SUM: predicted R[A,3] = 3 + 1 = 4A prediction fills the missing cell; it is notan observed rating.
Read it this way: Keep user A and item 3 fixed through every stage. Their matching factor rows contribute 3 and 1. The predicted missing rating is 4, not a newly observed preference.
Check: Which two factor rows predict the missing A/item-3 entry? How do their matching coordinates produce 4?
Read it this way: The example user vector (1,2) and item vector (3,1) predict 1x3+2x1=5. This is a model estimate, not an observed rating.
Which observation would be required to call five a recorded rating?
Entry in user A’s rowObservationExplicit-rating loss
Item 1Rating 5Included
Item 3UnknownExcluded
Item 4Rating 1Included

The objective

Minimize regularized squared error on observed ratings :

The observed set excludes unknown entries, and controls the stated L2 penalty. With biases, use , defining global mean and user/item offsets. Fit these together; adding afterward changes four to . That exceeds a 1-5 rating scale and is not automatically a calibrated prediction.

Change observed signal

New task: replace explicit ratings with clicks whose exposure is not fully observed.

Picture and change: a confidence-weighted implicit model uses

Here is an interaction indicator and is modeling confidence, not an identified exposure probability. Unlike explicit-rating loss, this objective includes all pairs, usually with lower confidence for unobserved interactions.

Check: a separate two-item fixture has scores , preferences , and confidences . Its unregularized loss is , not the positive-only value . A never-shown item’s weak zero preference remains an assumption, not evidence of dislike.

Use when: revise the objective and evaluation when observation semantics change.

Cold start

Change item availability

New task: score a new item without a trained ID row.

Picture and change: use a separately validated feature encoder or content/context fallback, rather than a nonexistent lookup row.

Check: if an encoder supplies , user A’s zero-bias score is . Increasing alone cannot produce a trained row for an unseen ID. An encoder can compute a vector without proving cold-item accuracy.

Use when: evaluate the cold-item slice and fallback separately from seen-ID performance.

Training

Squared-error factorization is nonconvex jointly, but convex in either factor when the other is fixed. ALS solves conditional ridge problems; SGD updates selected rows. For one pair’s squared residual and two-row L2 penalty, hold biases fixed and save both old rows. Set , then compute simultaneously

Using the updated user row for the item gradient changes this step. Sampling and regularization scaling must match the full objective.

Properties

For orthogonal , replacing with preserves predictions and L2 norms. The fixture rows can become and while retaining dot product four. Tune and regularization against matched baselines; coordinates are not uniquely identifiable tastes.

Connection to two-tower models

Two-tower retrieval replaces free rows with feature encoders . An ID-only tower still lacks trained parameters for new IDs. Sampled retrieval losses differ from squared-error ratings and all-pair implicit fitting.

When to use plain MF in 2026

MF can be a rating baseline, prototype, or embedding initializer. Choose architecture from task, latency, features, and measured validation, not a universal deployment-prevalence claim.

Common pitfalls

Dot-product prediction does not validate within-type cosine; normalization changes scores. Compare bias baselines and ranking metrics when top-K quality matters; RMSE answers a different question.

Can a PCA rotation identify unique causal tastes?

Answer

No. It chooses coordinates without removing equivalent factorizations or establishing causal meanings.

References: Koren et al. (2009), Hu et al. (2008).