CTU logo
NIE-PML · CTU FIT

Matrix Factorisation

Personalised Machine Learning

Basic Concepts

A recommender system connects two kinds of entities:

User A person to whom the system makes recommendations
Item Anything that can be recommended: a movie, a product, a song, a job posting
An interaction is a piece of feedback that a user gives an item.

Explicit vs. Implicit Feedback

Explicit The user directly states a preference
Anna rates “Pirates of the Caribbean” 4 out of 5 stars.

Clean signal, but rare

ratings thumbs up/down reviews
Implicit Preference is inferred from behaviour
Bob watches 80% of “Pirates of the Caribbean”.

Abundant, but noisier

clicks views purchases watch time
In practice, most systems rely on implicit feedback, because it is far more abundant than explicit ratings.

Recommender as a Matrix

users items
$X_{ij}$
user i's interaction with item j
$X \in \mathbb{R}^{m \times n}$

The Rating Matrix

The rating matrix $X \in \{\mathbb{R} \cup \, ?\}^{m \times n}$ stores users' explicit feedback:

$X=$
1 ? ? 2 ? 1 ? 2 3 ? 2 1 1 5 5 ? ? 5 ? ? 2 ? ? 3 1 2 1 2 3 2 1 1 5 5 5 2 3 ? ? ? ? ? ? ? ? ? ? ?
$X_{2,5}=2$: user 2 rated item 5 with 2 stars.
$X_{4,4}=\,?$: user 4 has not rated item 4.
Known entries are actual ratings:
$\Omega = \{(i,j) : X_{ij} \text{ is observed}\}$
A ? marks a missing entry, not a zero: a value we would like to predict.
We typically observe only a few entries (less than 1%), i.e. $|\Omega| \ll mn$.

The Factorisation Model

The idea is to approximate $X$ with two tall, thin matrices:

$X$
$\approx$
$U$
$\times$
$V^\top$
$\mathbf{u}_i$
$\mathbf{v}_j$
$\hat{X}_{ij}=\textcolor{#2e7d32}{\mathbf{u}_i^\top} \textcolor{#1f5fbf}{\mathbf{v}_j}$
$U \in \mathbb{R}^{m\times d}$ and $V \in \mathbb{R}^{n\times d}$, with $d \ll \min(m,n)$

In machine learning terms, we would like to find:

$$\min_{U,V} \|X - UV^\top\|_{\operatorname{Fro}}^2 \quad \text{with} \quad d \ll \min(m,n)$$

Geometry of the Prediction

Bob Anna Titanic The Bodyguard Bob Anna Titanic The Bodyguard Titanic Anna Bob
$d = 2$
Dimension 1 Dimension 2
$$\hat{X}_{ij} = \textcolor{#1b7a3a}{\mathbf{u}_i^\top} \textcolor{#1f5fbf}{\mathbf{v}_j} = \|\textcolor{#1b7a3a}{\mathbf{u}_i}\|\,\|\textcolor{#1f5fbf}{\mathbf{v}_j}\|\cos\theta$$
The projection of user $i$ shows how the user leans toward each latent dimension.
Items work the same way: Titanic is purely dimension 2; The Bodyguard is a milder mix of both.
The magnitude $\|\mathbf{u}_i\|$ reflects how much a user likes the dimensions. $\|\mathbf{v}_j\|$ reflects how much a movie contains the dimensions.
The angle $\theta$ between a user and an item vector reflects how well they align.

Fully Known Case

Titanic Casablanca Terminator Anna Bob Charlie 3.75 3.50 0.50 5.00 -0.50 4.50 -0.75 1.00 4.00 3.75 3.50 0.50 5.00 4.50 1.00 -0.50 -0.75 4.00
$X$
Anna Bob Charlie Titanic Casablanca Terminator

Singular Value Decomposition

Definition
Recall that we define the SVD of every matrix $X \in \mathbb{R}^{m\times n}$ as $$X = U' D' (V')^\top,$$ where $U' \in \mathbb{R}^{m\times d}$ and $V' \in \mathbb{R}^{n\times d}$ have orthonormal columns, the singular vectors (i.e. $(U')^\top U' = (V')^\top V' = I_d$), and $D' = \operatorname{diag}(\sigma_1,\dots,\sigma_d)$ is square and diagonal, holding the singular values $\sigma_1 \geq \dots \geq \sigma_d > 0$, for $d = \operatorname{rank}(X)$.

SVD of Our Fully Known Case

3.755.00-0.50 3.504.50-0.75 0.501.004.00 AnnaBobCharlie TitanicCasablancaTerminator
$=$
0.73-0.04-0.68 0.67-0.110.73 0.100.990.05 AnnaBobCharlie
$\times$
8.54 4.09 0.06
$\times$
0.600.80-0.05 -0.010.071.00 0.80-0.600.05 TitanicCasablancaTerminator
$X$
$U'$
$D'$
$(V')^\top$
$D'$ has no zero singular value, so $X$ is of full rank. This means we cannot achieve a perfect reconstruction $X = UV^\top$ with $U \in \mathbb{R}^{m\times d}$, $V \in \mathbb{R}^{n\times d}$, for $d < \min(m,n)$.
Let $\operatorname{rank}(A)$ denote the rank of a matrix $A \in \mathbb{R}^{m\times n}$. Properties and definitions:
  • $\operatorname{rank}(A) = \operatorname{rank}(A^\top)$.
  • WLOG, if $m \geq n$, matrix $A$ is considered full rank when $\operatorname{rank}(A) = n$. In this case, $n$ is also the maximum possible rank.
  • For matrices where $m = n$, an inverse $A^{-1}$ exists if and only if $A$ is full rank.
  • A matrix is said to be of low rank (or rank deficient) if it does not have full rank.
  • $\operatorname{rank}(AB) \leq \min(\operatorname{rank}(A), \operatorname{rank}(B))$.
$=$
2.14-0.08-0.17 1.96-0.220.18 0.302.010.01 AnnaBobCharlie
$\times$
1.762.32-0.16 -0.020.152.02 0.20-0.150.01 TitanicCasablancaTerminator
$U$
$V^\top$
Where
$U = U'\sqrt{D'}$
$V = V'\sqrt{D'}$

Geometry of U and V

2.14 -0.08 -0.17 1.96 -0.22 0.18 0.30 2.01 0.01 2.14 -0.08 -0.17 1.96 -0.22 0.18 0.30 2.01 0.01 Anna Bob Charlie D1 D2 D3 Drama Action Noise
$U$
1.76 -0.02 0.20 2.32 0.15 -0.15 -0.16 2.02 0.01 1.76 -0.02 0.20 2.32 0.15 -0.15 -0.16 2.02 0.01 Titanic Casablanca Terminator D1 D2 D3 Drama Action Noise
$V$
D1 D2 D3 Drama Action Noise Titanic Casablanca Terminator Anna Bob Charlie Titanic Casablanca Terminator

Low-Rank Approximation: Fully Known Case

Finding the best rank-$d$ approximation of $X$ is equivalent to solving:

$$\min_{\operatorname{rank}(Y) \leq d} \|X-Y\|_{\operatorname{Fro}}^2$$

Definition
Let $D' \in \mathbb{R}^{d\times d}$, $D' = \operatorname{diag}(\sigma_1,\ldots,\sigma_d)$, be the diagonal matrix of singular values of $X$, with $\sigma_i \geq 0$. For $1 \le r \le d$, the truncated SVD operator keeps $\sigma_1,\ldots,\sigma_r$ and sets $\sigma_{r+1},\ldots,\sigma_d$ to zero: $$\mathcal{T}_r(D') := \operatorname{diag}(\sigma_1,\ldots,\sigma_r,0,\ldots,0)$$
Eckart–Young–Mirsky Theorem
For any $X \in \mathbb{R}^{m\times n}$ and $1 \le r \le \operatorname{rank}(X)$:
$$U'\,\mathcal{T}_r(D')\,(V')^\top = \operatorname*{argmin}_{\operatorname{rank}(Y) \leq r} \|X-Y\|_{\operatorname{Fro}}^2$$
3.755.00-0.50 3.504.50-0.75 0.501.004.00 AnnaBobCharlie TitanicCasablancaTerminator
$=$
0.73-0.04-0.68 0.67-0.110.73 0.100.990.05 AnnaBobCharlie
$\times$
8.54 4.09 0.06 0
$\times$
0.600.80-0.05 -0.010.071.00 0.80-0.600.05 TitanicCasablancaTerminator
$X$
$U'$
$D'$
$\mathcal{T}_r(D')$
Suppose $r = 2$
$(V')^\top$
Definition
Let $D' \in \mathbb{R}^{d\times d}$, $D' = \operatorname{diag}(\sigma_1,\ldots,\sigma_d)$, be the diagonal matrix of singular values of $X$, with $\sigma_i \geq 0$. For $1 \le r \le d$, the truncated SVD operator keeps $\sigma_1,\ldots,\sigma_r$ and sets $\sigma_{r+1},\ldots,\sigma_d$ to zero: $$\mathcal{T}_r(D') := \operatorname{diag}(\sigma_1,\ldots,\sigma_r,0,\ldots,0)$$
Eckart–Young–Mirsky Theorem
For any $X \in \mathbb{R}^{m\times n}$ and $1 \le r \le \operatorname{rank}(X)$:
$$U'\,\mathcal{T}_r(D')\,(V')^\top = \operatorname*{argmin}_{\operatorname{rank}(Y) \leq r} \|X-Y\|_{\operatorname{Fro}}^2$$
$=$
2.14-0.08-0.17 1.96-0.220.18 0.302.010.01 000 AnnaBobCharlie DramaActionNoise
$\times$
1.762.32-0.16 -0.020.152.02 0.20-0.150.01 000 TitanicCasablancaTerminator DramaActionNoise
$U$
$V^\top$
Where
$U = U'\sqrt{D'}$
$V = V'\sqrt{D'}$
Where
$U = U'\sqrt{\mathcal{T}_r(D')}$
$V = V'\sqrt{\mathcal{T}_r(D')}$

New Geometry of U and V

2.14-0.08 2.14-0.08 0 Anna 1.96-0.22 1.96-0.22 0 Bob 0.302.01 0.302.01 0 Charlie Drama Action Noise
$U$
1.76-0.02 1.76-0.02 0 Titanic 2.320.15 2.320.15 0 Casablanca -0.162.02 -0.162.02 0 Terminator Drama Action Noise
$V$
Drama Action Titanic Casablanca Terminator Anna Bob Charlie Titanic Casablanca Terminator

Rank 3 vs. Rank 2 Approximation

Rank 3: Reconstruction of $X$
Drama Action Noise Titanic Casablanca Terminator Anna Bob Charlie
Drama, Action and Noise
Rank 2: Approximation of $X$
Drama Action Titanic Casablanca Terminator Anna Bob Charlie
Noise dropped: Drama and Action only

Can We Factorise an Incomplete Matrix?

Suppose only three entries of $X \in \mathbb{R}^{2\times 2}$ are observed: $\;X = \begin{pmatrix} 1 & 3 \\ 2 & \color{#D50032}{?} \end{pmatrix}$

Question
How many matrices are consistent with the observed entries?
Infinitely many: every $t \in \mathbb{R}$ gives a consistent matrix $\begin{pmatrix} 1 & 3 \\ 2 & t \end{pmatrix}$.
The factorisation therefore depends on the assumptions we impose on $X$.
Rank-one assumption
If we assume $\operatorname{rank}(X) = 1$, the second column must be a multiple of the first. Since $3 = 3 \cdot 1$, we need $\begin{pmatrix} 3 \\ t \end{pmatrix} = 3 \begin{pmatrix} 1 \\ 2 \end{pmatrix}$, so $t = 6$ is the unique completion. As a possible factorisation: $$X = UV^\top = \begin{pmatrix} 1 \\ 2 \end{pmatrix} \begin{pmatrix} 1 & 3 \end{pmatrix} = \begin{pmatrix} 1 & 3 \\ 2 & 6 \end{pmatrix}.$$

MF for Explicit Feedback

In a recommender, we observe only very few ratings.

For instance: the Netflix Prize
480K users × 18K movies, 100M ratings
only ≈ 1% of the entries are observed
Recall
$(i,j) \notin \Omega$: the rating is unknown, not zero
$\Omega = \{(i,j) : X_{ij} \text{ is observed}\}$
Matrix factorisation for explicit feedback
Given a partially observed matrix $X$, a latent dimension $d$ and a regularisation constant $\lambda > 0$, learn $U \in \mathbb{R}^{m\times d}$ and $V \in \mathbb{R}^{n\times d}$:
$$\operatorname*{argmin}_{U,V} \; \underbrace{\sum_{(i,j) \in \Omega} \big(X_{ij} - \mathbf{u}_i^\top \mathbf{v}_j\big)^2}_{\text{fit the observed ratings}} \; + \; \underbrace{\lambda \big( \|U\|_{\operatorname{Fro}}^2 + \|V\|_{\operatorname{Fro}}^2 \big)}_{\text{regularisation}}$$
Without regularisation, a user with few ratings is fitted perfectly by a large $\mathbf{u}_i$ that predicts poorly elsewhere.

Alternating Least Squares (ALS)

We want to minimise

$$\mathcal{L}(U,V) = \sum_{(i,j) \in \Omega} \big(X_{ij} - \mathbf{u}_i^\top \mathbf{v}_j\big)^2 + \lambda \big( \|U\|_{\operatorname{Fro}}^2 + \|V\|_{\operatorname{Fro}}^2 \big)$$

Idea: never optimise $U$ and $V$ at the same time. Fix one, update the other, and alternate.

1 · Initialise
Fill $U$ and $V$ with small random values.
2 · Fix $V$, update users
For every user $i$, find the best $\mathbf{u}_i$ from their own ratings.
3 · Fix $U$, update items
For every item $j$, find the best $\mathbf{v}_j$ from the ratings it received.
Repeat steps 2 and 3 until convergence:
$V^{(0)}$→$U^{(1)}$→$V^{(1)}$→$U^{(2)}$→$V^{(2)}$→$\cdots$

ALS: Updating One User

observed
missing
user $i$
$X$
$\approx$
$\mathbf{u}_i^\top$
$U$
$\times$
$V^\top$
FIXED
USER $i$ ONLY
$=$
$\times$
$X_{\Omega^i}$
$|\Omega^i| \times 1$
$V_{\Omega^i}$
$|\Omega^i| \times d$
$\mathbf{u}_i$
$d \times 1$

With $V$ fixed, user $i$'s observed ratings depend only on $\mathbf{u}_i$: a small linear system.

One User Is a Ridge Regression

USER $i$ ONLY
$=$
$\times$
$X_{\Omega^i}$
$|\Omega^i| \times 1$
$V_{\Omega^i}$
$|\Omega^i| \times d$
$\mathbf{u}_i$
$d \times 1$
Notation
$\Omega^i = \{j : (i,j) \in \Omega\}$: items rated by user $i$
$\textcolor{#2e7d32}{X_{\Omega^i}} \in \mathbb{R}^{|\Omega^i|}$: their ratings (targets)
$\textcolor{#1f5fbf}{V_{\Omega^i}} \in \mathbb{R}^{|\Omega^i| \times d}$: rows $\mathbf{v}_j^\top$ (features)
1 · Objective, with $V$ fixed
$$\min_{\mathbf{u}_i} \sum_{j \in \Omega^i} \big(X_{ij} - \mathbf{v}_j^\top \mathbf{u}_i\big)^2 + \lambda \|\mathbf{u}_i\|_2^2$$
2 · Matrix form
$$\min_{\mathbf{u}_i} \big\|\textcolor{#2e7d32}{X_{\Omega^i}} - \textcolor{#1f5fbf}{V_{\Omega^i}} \mathbf{u}_i\big\|_2^2 + \lambda \|\mathbf{u}_i\|_2^2$$
3 · Optimality condition
$$-2\,\textcolor{#1f5fbf}{V_{\Omega^i}^\top} \big(\textcolor{#2e7d32}{X_{\Omega^i}} - \textcolor{#1f5fbf}{V_{\Omega^i}} \mathbf{u}_i\big) + 2 \lambda \mathbf{u}_i = \mathbf{0}$$
Closed form
$$\hat{\mathbf{u}}_i = \big(\textcolor{#1f5fbf}{V_{\Omega^i}^\top} \textcolor{#1f5fbf}{V_{\Omega^i}} + \lambda I_d\big)^{-1} \textcolor{#1f5fbf}{V_{\Omega^i}^\top} \textcolor{#2e7d32}{X_{\Omega^i}}$$

Fixing U and Updating One Item

ITEM $j$ ONLY
$=$
$\times$
$X_{\Omega^j}$
$|\Omega^j| \times 1$
$U_{\Omega^j}$
$|\Omega^j| \times d$
$\mathbf{v}_j$
$d \times 1$
Notation
$\Omega^j = \{i : (i,j) \in \Omega\}$: users who rated item $j$
$\textcolor{#1f5fbf}{X_{\Omega^j}} \in \mathbb{R}^{|\Omega^j|}$: their ratings (targets)
$\textcolor{#2e7d32}{U_{\Omega^j}} \in \mathbb{R}^{|\Omega^j| \times d}$: rows $\mathbf{u}_i^\top$ (features)
1 · Objective, with $U$ fixed
$$\min_{\mathbf{v}_j} \sum_{i \in \Omega^j} \big(X_{ij} - \mathbf{u}_i^\top \mathbf{v}_j\big)^2 + \lambda \|\mathbf{v}_j\|_2^2$$
2 · Matrix form
$$\min_{\mathbf{v}_j} \big\|\textcolor{#1f5fbf}{X_{\Omega^j}} - \textcolor{#2e7d32}{U_{\Omega^j}} \mathbf{v}_j\big\|_2^2 + \lambda \|\mathbf{v}_j\|_2^2$$
Closed form
$$\hat{\mathbf{v}}_j = \big(\textcolor{#2e7d32}{U_{\Omega^j}^\top} \textcolor{#2e7d32}{U_{\Omega^j}} + \lambda I_d\big)^{-1} \textcolor{#2e7d32}{U_{\Omega^j}^\top} \textcolor{#1f5fbf}{X_{\Omega^j}}$$

The ALS Algorithm

Algorithm: Alternating Least Squares
Input: observed ratings $X_{\Omega}$, latent dimension $d$, $\lambda > 0$
Initialise $U$ and $V$ randomly
repeat until convergence
for each user $i$: $\;\mathbf{u}_i \leftarrow \big(V_{\Omega^i}^\top V_{\Omega^i} + \lambda I_d\big)^{-1} V_{\Omega^i}^\top X_{\Omega^i}$
for each item $j$: $\;\mathbf{v}_j \leftarrow \big(U_{\Omega^j}^\top U_{\Omega^j} + \lambda I_d\big)^{-1} U_{\Omega^j}^\top X_{\Omega^j}$
Convergence
$\mathcal{L}$ never increases, so we can stop when it stops decreasing. In practice, we run a fixed number of iterations or use early stopping.
Parallelism
Given a fixed $V$, the users are independent (and so are the items given a fixed $U$): each loop runs in parallel.

ALS Geometrically: Updating One User

3.755.00-0.50Anna3.504.50-0.75Bob0.501.004.00Charlie4.00-0.75Diana?5.08TitanicCasablancaTerminator
$X$
DramaActionTitanicCasablancaTerminator
$V$ fixed
current $\mathbf{u}_{\text{Diana}}$
$\mathbf{u}_{\text{Diana}}$

$$\hat{\mathbf{u}}_{\text{Diana}} = \big(V_{\Omega^{\text{Diana}}}^\top V_{\Omega^{\text{Diana}}} + \lambda I_d\big)^{-1} V_{\Omega^{\text{Diana}}}^\top X_{\Omega^{\text{Diana}}} \approx \begin{pmatrix} 2.20 \\ -0.19 \end{pmatrix}, \qquad \lambda = 0.1$$

Its dot products fit her ratings ($3.88 \approx 4$, $-0.74 \approx -0.75$) and predict Casablanca $\approx 5.08$.

What Changes With Implicit Feedback?

MF for Implicit Feedback

In practice, we observe far more implicit than explicit feedback.

Explicit
Anna rates “Pirates of the Caribbean” 4 out of 5 stars.
a preference: Anna likes it
Implicit
Bob watches 80% of “Pirates of the Caribbean”.
a behaviour: does Bob like it?
Question
Bob also watches 40% of “Titanic”. Does he like Pirates more? Twice as much?
The amount watched tells us how confident we are that Bob likes a movie, not how much he likes it.
And a movie Bob never watched is not a dislike: he may simply not know it.

Preference and Confidence

Split the interaction matrix $X$ into two matrices.

00.950.6000.800.4000000.201.000.500.9000.10PiratesTitanicCasablancaTerminator
$X$
fraction watched
AnnaBobCharlieDiana
0110110000111101PiratesTitanicCasablancaTerminator
$P_{ij} = \begin{cases} 1 & X_{ij} > 0 \\ 0 & X_{ij} = 0 \end{cases}$
preference: did $i$ watch $j$?
110.57195111131161012PiratesTitanicCasablancaTerminator
$C_{ij} = 1 + \alpha X_{ij}, \; \alpha = 10$
confidence: how sure are we?
Bob never watched Casablanca: $P_{ij} = 0$ with low confidence $C_{ij} = 1$, not ignored

The Learning Problem for Implicit Feedback

Why not explicit MF on $P$?
It fits only the entries with $X_{ij} > 0$, where $P_{ij} = 1$ always.
predicting $1$ everywhere is a perfect fit
Instead
Fit every pair $(i,j)$, weighting its error by its confidence $C_{ij}$.
zeros count, but with low confidence
Matrix factorisation for implicit feedback
Given preferences $P$, confidences $C$, a latent dimension $d$ and a regularisation constant $\lambda > 0$, learn $U \in \mathbb{R}^{m\times d}$ and $V \in \mathbb{R}^{n\times d}$:
$$\operatorname*{argmin}_{U,V} \; \underbrace{\sum_{i=1}^{m} \sum_{j=1}^{n} C_{ij} \big(P_{ij} - \mathbf{u}_i^\top \mathbf{v}_j\big)^2}_{\text{confidence-weighted fit on all pairs}} \; + \; \underbrace{\lambda \big( \|U\|_{\operatorname{Fro}}^2 + \|V\|_{\operatorname{Fro}}^2 \big)}_{\text{regularisation}}$$

Implicit ALS: Updating One User

$$\mathcal{L}_i(\mathbf{u}_i) = \sum_{j=1}^{n} \Big(\sqrt{\textcolor{#6a3d9a}{C_{ij}}}\,\big(\textcolor{#2e7d32}{P_{ij}} - \textcolor{#1f5fbf}{\mathbf{v}_j^\top} \mathbf{u}_i\big)\Big)^2 + \lambda \|\mathbf{u}_i\|_2^2$$

$P_{ij} = 1$
$P_{ij} = 0$
$C$
confidence
user $i$
$P$
preference
$\approx$
$\mathbf{u}_i^\top$
$U$
$\times$
$V^\top$
FIXED
$\mathbf{v}_1$
$\mathbf{v}_2$
USER $i$ ONLY
$j = 1$: $\sqrt{C_{i1}}\,\big(P_{i1} - \mathbf{v}_1^\top \mathbf{u}_i\big)$
$j = 2$: $\sqrt{C_{i2}}\,\big(P_{i2} - \mathbf{v}_2^\top \mathbf{u}_i\big)$
$j = 1, \ldots, n$: $\sqrt{C^i}\,\big(P_i - V\mathbf{u}_i\big)$
$\mathbf{v}_1^\top$
$-$
$\mathbf{u}_i$
$\mathbf{v}_2^\top$
$\sqrt{C^i}$
$n \times n$
$P_i$
$n \times 1$
$V$
$n \times d$
$d \times 1$

One User Is a Weighted Ridge Regression

USER $i$ ONLY
$-$
$\sqrt{C^i}$
$n \times n$
$P_i$
$n \times 1$
$V$
$n \times d$
$\mathbf{u}_i$
$d \times 1$
Notation
$\textcolor{#6a3d9a}{C^i} = \operatorname{diag}(C_{i1}, \ldots, C_{in}) \in \mathbb{R}^{n \times n}$ (weights)
$\textcolor{#2e7d32}{P_i} \in \mathbb{R}^{n}$: preferences of user $i$ (targets)
$\textcolor{#1f5fbf}{V} \in \mathbb{R}^{n \times d}$: all item vectors (features)
1 · Objective, with $V$ fixed
$$\min_{\mathbf{u}_i} \sum_{j=1}^{n} C_{ij} \big(P_{ij} - \mathbf{v}_j^\top \mathbf{u}_i\big)^2 + \lambda \|\mathbf{u}_i\|_2^2$$
2 · Matrix form
$$\min_{\mathbf{u}_i} \big\|\sqrt{\textcolor{#6a3d9a}{C^i}}\,\big(\textcolor{#2e7d32}{P_i} - \textcolor{#1f5fbf}{V} \mathbf{u}_i\big)\big\|_2^2 + \lambda \|\mathbf{u}_i\|_2^2$$
$\sqrt{C^i}$ is diagonal, so $\big(\sqrt{C^i}\big)^\top \sqrt{C^i} = C^i$
3 · Optimality condition
$$-2\,\textcolor{#1f5fbf}{V^\top} \textcolor{#6a3d9a}{C^i} \big(\textcolor{#2e7d32}{P_i} - \textcolor{#1f5fbf}{V} \mathbf{u}_i\big) + 2 \lambda \mathbf{u}_i = \mathbf{0}$$
Closed form
$$\hat{\mathbf{u}}_i = \big(\textcolor{#1f5fbf}{V^\top} \textcolor{#6a3d9a}{C^i} \textcolor{#1f5fbf}{V} + \lambda I_d\big)^{-1} \textcolor{#1f5fbf}{V^\top} \textcolor{#6a3d9a}{C^i} \textcolor{#2e7d32}{P_i}$$
Items, with $U$ fixed: $\hat{\mathbf{v}}_j = \big(U^\top C^j U + \lambda I_d\big)^{-1} U^\top C^j P_j$

From Factors to Recommendations

Once $U$ and $V$ are learned, score every item $j$ for user $i$: $\hat{X}_{ij} = \mathbf{u}_i^\top \mathbf{v}_j$, that is, $\mathbf{s}_i = V \mathbf{u}_i$.

Our user: Bob has watched 80% of “Pirates of the Caribbean” and 40% of “Titanic”.
1 · Score
Pirates0.61.00.82Titanic1.20.10.86Casablanca1.30.00.89Terminator0.11.30.60Alien0.01.10.45Up0.70.50.690.690.41
$\times$
$=$
$V$
$\mathbf{u}_{\text{Bob}}$
$\mathbf{s}_{\text{Bob}}$
2 · Filter
Pirates0.82watchedTitanic0.86watchedCasablanca0.89Terminator0.60Alien0.45Up0.69
remove $j \in \Omega^{\text{Bob}}$
3 · Rank and cut
1Casablanca0.892Up0.693Terminator0.604Alien0.45
top-$K$ with $K = 2$: recommend to Bob
$$\operatorname{Rec}_K(i) = \operatorname*{TopK}_{j \notin \Omega^i} \; \mathbf{u}_i^\top \mathbf{v}_j, \qquad \Omega^i = \{j : X_{ij} > 0\}$$
For implicit feedback, only the order of the scores matters: they are not ratings.
CTU logo
NIE-PML · CTU FIT

Obrigado!

Questions?