AI Wiki中文/EN

Implicit feedback: a count changes confidence, not the preference label

隐式反馈建模

Derive confidence-weighted ALS, include unobserved pairs and check the sparse normal equations against a dense solve.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Five plays are not a five-star rating

A song played five times may be a favorite, background music, or an autoplay artifact. A song never played may be disliked, unknown, or unavailable. Implicit feedback records behavior rather than an explicit judgment. Its abundance does not remove that ambiguity.

Hu, Koren and Volinsky separate a binary preference target from confidence in that target. A positive interaction count marks observed interest, while its magnitude changes the weight of the fitting error. Missing interactions still contribute a weaker zero-target term. PDF 2–4 This differs from explicit-rating factorization, where unobserved ratings contribute no error. Koren and colleagues also discuss implicit information as evidence distinct from explicit ratings. PDF 2–4

The zero target is a modeling convention. It is not a verified statement that the user dislikes every unseen item.

Positive counts share a binary target while confidence weights differ; the one-dimensional solve is separate.
Positive counts share a binary target while confidence weights differ; the one-dimensional solve is separate.

An all-pair loss with unequal weights

Let r_ui be a nonnegative interaction count. In the linear confidence scheme used here, alpha is a nonnegative weighting parameter:

pui=1[rui>0],cui=1+αrui.p_{ui}=\mathbf1[r_{ui}>0],\qquad c_{ui}=1+\alpha r_{ui}.

Counts 1 and 5 therefore have the same preference target, 1. With alpha=4 their confidence weights are 5 and 21; a zero count has target 0 and weight 1. Confidence is a loss weight, not a calibrated probability that the user likes the item. This distinction is central to the source model. PDF 4, equations 1–3

For user factors x_u and item factors y_i of dimension d, minimize over all U I pairs:

J=∑u=1U∑i=1Icui(pui−xu⊤yi)2+λ(∑u∥xu∥22+∑i∥yi∥22),λ>0.J=\sum_{u=1}^{U}\sum_{i=1}^{I}c_{ui}(p_{ui}-x_u^\top y_i)^2+\lambda\left(\sum_u\|x_u\|_2^2+\sum_i\|y_i\|_2^2\right),\qquad\lambda>0.

The many unit-weight unobserved terms are part of this objective. Dropping them while retaining only positive events implements another model. Predictions are real-valued scores; they need not lie between zero and one.

Fix Y, the I-by-d item matrix. Let C_u be diagonal with the user’s confidence weights, and let p_u contain that user’s preference targets. Differentiate the quadratic user block and set its gradient to zero:

(Y⊤CuY+λI)xu=Y⊤Cupu.(Y^\top C_uY+\lambda I)x_u=Y^\top C_up_u.

The positive ridge term makes the system invertible. We can avoid forming C_u or scanning every item separately for every user by splitting it into an identity and sparse corrections:

Y⊤CuY=Y⊤Y+∑i:rui>0(cui−1)yiyi⊤.Y^\top C_uY=Y^\top Y+\sum_{i:r_{ui}>0}(c_{ui}-1)y_i y_i^\top.

The shared Gram matrix Y-transpose-Y accounts for all unit-weight terms, including unobserved items. Since preference is zero off the observed set, the right-hand side simplifies to:

Y⊤Cupu=∑i:rui>0cuiyi.Y^\top C_up_u=\sum_{i:r_{ui}>0}c_{ui}y_i.

These identities preserve the dense objective; they do not discard unseen pairs. Update every user with Y fixed, then exchange the roles and update every item. PDF 4, ALS derivation

A one-dimensional hand calculation makes confidence visible. Fix two item factors at 1, observe only the first item, and use lambda=1. If its confidence is c, then:

x=cc+1+1;c=2⇒x=12,c=10⇒x=56.x=\frac{c}{c+1+1};\qquad c=2\Rightarrow x=\tfrac12,\quad c=10\Rightarrow x=\tfrac56.

The denominator includes the unobserved item’s unit-weight contribution and the ridge penalty. More confidence pulls the score toward the observed target, while those two terms resist it.

Check the efficient solve against a dense one

The complete original program uses Python 3.12 and NumPy 1.26.4. Its synthetic 6-by-6 count table contains two overlapping groups of interested users and a final user with no interactions. Use rank 2, alpha 4, lambda 0.2, 15 full alternating passes and initialization seed 4.

"""Original confidence-weighted implicit ALS; no missing-as-explicit-dislike claim."""
import json
import numpy as np


def signals(counts, alpha=4.):
    r = np.asarray(counts,float)
    if r.ndim != 2 or min(r.shape)==0 or not np.isfinite(r).all() or (r<0).any() or not np.isfinite(alpha) or alpha<0:
        raise ValueError('finite nonnegative counts and alpha required')
    return (r>0).astype(float),1+alpha*r


def solve_rows(counts, other, alpha=4., regularization=.2):
    counts=np.asarray(counts,float)
    preference,confidence = signals(counts,alpha); y=np.asarray(other,float)
    if y.ndim!=2 or y.shape[0]!=counts.shape[1] or y.shape[1]==0 or not np.isfinite(y).all() or not np.isfinite(regularization) or regularization<=0:
        raise ValueError('compatible factors and positive ridge required')
    gram = y.T@y; k=y.shape[1]; out=np.zeros((counts.shape[0],k))
    for u in range(len(counts)):
        seen = counts[u]>0; ys=y[seen]; c=confidence[u,seen]
        a = gram+(ys.T*(c-1))@ys+regularization*np.eye(k)
        b = ys.T@c
        out[u] = np.linalg.solve(a,b)
    return out


def objective(counts, x, y, alpha=4., regularization=.2):
    p,c=signals(counts,alpha)
    return float(np.sum(c*(p-x@y.T)**2)+regularization*(np.sum(x*x)+np.sum(y*y)))


def fit(counts, rank=2, steps=15, alpha=4., regularization=.2, seed=4):
    r=np.asarray(counts,float); signals(r,alpha)
    if not isinstance(rank,int) or rank<1 or not isinstance(steps,int) or steps<0 or not np.isfinite(regularization) or regularization<=0:
        raise ValueError('positive rank/ridge and nonnegative steps required')
    rng=np.random.default_rng(seed);x=rng.normal(0,.1,(len(r),rank));y=rng.normal(0,.1,(r.shape[1],rank))
    history=[objective(r,x,y,alpha,regularization)]
    for _ in range(steps):
        x=solve_rows(r,y,alpha,regularization);history.append(objective(r,x,y,alpha,regularization))
        y=solve_rows(r.T,x,alpha,regularization);history.append(objective(r,x,y,alpha,regularization))
    return x,y,history


def recommend(counts, x, y, user, k=3):
    if not isinstance(k,int) or k<0:raise ValueError('nonnegative k required')
    scores=x[user]@y.T
    return sorted([i for i in range(len(y)) if counts[user,i]==0],key=lambda i:(-scores[i],i))[:k]


def demo():
    r=np.array([[5,2,0,0,0,0],[2,3,1,0,0,0],[0,1,4,0,0,0],[0,0,0,5,2,0],[0,0,0,2,3,4],[0,0,0,0,0,0]],float)
    p,c=signals(r);x,y,h=fit(r)
    low=solve_rows(np.array([[1.,0.]]),np.array([[1.],[1.]]),alpha=1,regularization=1)
    high=solve_rows(np.array([[1.,0.]]),np.array([[1.],[1.]]),alpha=9,regularization=1)
    return dict(counts=r.tolist(),preference=p.tolist(),confidence=c.tolist(),history=h,
                recommendations=recommend(r,x,y,0),scores=(x@y.T).tolist(),
                cold_user=x[-1].tolist(),confidence_example=[float(low[0,0]),float(high[0,0])])


if __name__=='__main__':print(json.dumps(demo(),allow_nan=False))

The objective falls from about 146.984484 to 7.086958. After removing items already consumed by user 0, the returned list is [2,5,4]. This is an inspected model output, not a measured ranking-quality result: the example has no held-out preference labels. The empty user’s factor is exactly [0,0], so their scores tie. That reveals the need for a separate new-user policy.

The independent dense test explicitly constructs each C_u and solves its normal equation, then compares with solve_rows. Another hand test uses one observed and one unobserved pair: with user factor 1, item factors 1 and 2, and lambda 0.2, the loss is 5.2. The unobserved prediction contributes 4 and regularization contributes 1.2. Tests also check the half-pass loss decreases, confidence example, invalid counts and exclusion of consumed items.

With sparse counts, building a shared Gram matrix costs O(I d²), user corrections cost O(nnz(r) d²), and U dense user solves cost O(U d³); item updates have the analogous costs. This teaching code stores counts densely, scans them to find nonzeros and materializes U I scores for objective logging, adding O(U I(d+1)) work and O(U I) storage per full pass. Sparse inputs and observed-only corrections do not by themselves remove that logging cost. Recommendation here also scores and sorts all items for one user, taking O(I d + I log I).

Confidence cannot identify why an event occurred

Multiplying repeated plays by alpha strengthens their influence even if repetition came from autoplay. The source discusses the uncertainty of implicit behavior; a count transformation does not solve exposure bias or establish a causal preference. PDF 2 Define the event, deduplication and time window before fitting. Alpha and regularization should be selected on a separate validation split, not by looking for an attractive training loss.

No observations means the user block has a zero right-hand side and hence a zero solution. A metadata or popularity fallback can serve that user, but the ALS factors alone have learned no personal preference. Similarly, all-pair training is not an instruction to recommend unavailable items: eligibility and consumed-item policies belong in the surrounding recommendation pipeline.

Which term is still present?

  1. At alpha=4, compare counts 1 and 5. Answer: Both targets are 1; confidence weights are 5 and 21. Neither target equals the raw count.
  2. In the one-dimensional example, why is the denominator c+2? Answer: One added unit comes from the unobserved item with factor 1; the other comes from lambda=1.
  3. Does the Gram shortcut ignore unobserved items? Answer: No. Their baseline contribution is already inside Y-transpose-Y. Sparse corrections add only the extra confidence on observed pairs.
  4. Why can an empty user’s factor be zero even after many ALS passes? Answer: Their target vector stays zero, making the right-hand side zero. The positive definite system has the unique zero solution; extra iterations cannot invent personal evidence.

A weighted regression model, not a click-probability model

The derivation follows the confidence-weighted squared-loss model in Hu and colleagues; the 2009 overview supplies its relationship to explicit and implicit recommendation evidence. We read the recorded method pages and viewed the ALS equations. Our small solve is original and checked against the dense equations, without reproducing the paper’s dataset or results. Changing the confidence function, adding biases or replacing squared loss requires deriving and testing the corresponding objective again.

Make a prediction, then check

With positive interaction counts 1 and 5, how do binary preference labels differ?

Choose one answer

Learning objectives

  • Explain what an unobserved pair means in the loss without calling it an explicit dislike.
  • Run the original example, check its numerical result and explain one failure condition.

Prerequisites & connections

Explore related knowledge →

References

  1. Collaborative Filtering for Implicit Feedback Datasets
    Yifan Hu; Yehuda Koren; Chris Volinsky · 2008
  2. Matrix Factorization Techniques for Recommender Systems
    Yehuda Koren; Robert Bell; Chris Volinsky · 2009

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-23 · Single AI author. Scoped reading: Physical PDF 1 identity, 2 and 4 methods text, final 5500 characters of page 3; viewed page 4. Preference/confidence, all-pair objective and ALS. Physical PDF 1 identity, 2–4 methods text; viewed page 4 equations. Observed ratings, biases, SGD/ALS. No benchmark reproduction. 6 paired equations and four explained exercises. Checked all-pair confidence ALS against independently constructed dense equations, unobserved loss5.2, confidence hand values1/2 and5/6, cold user and consumed-item exclusion. No click-probability claim.

  • Checked all-pair confidence ALS against independently constructed dense equations, unobserved loss5.2, confidence hand values1/2 and5/6, cold user and consumed-item exclusion. No click-probability claim.
  • Four computed SVG variants per topic;11 numeric/geometry tests and36 responsive cases passed. Twelve selected captures visually checked;11 current images match previously viewed bytes and the revised matrix-factorization image was viewed again. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.