Sub topic 2
Explicit and implicit feedback
This chapter assumes you know basic Python, NumPy arrays, and averages. It covers the two kinds of signal a recommender learns from, and how each one becomes a user-item matrix.
Two kinds of signal
Collaborative filtering learns from what users did. That behavior comes in two forms.
- Explicit feedback is a user stating a preference directly. Examples are star ratings, thumbs up or down, and likes.
- Implicit feedback is a preference inferred from behavior. Examples are clicks, purchases, watch time, and play counts.
| Property | Explicit | Implicit |
|---|---|---|
| Volume | Low, since users must make an effort | High, collected automatically |
| Negative signal | Clear (a 1-star rating) | Absent (no click may mean "didn't see it") |
| Noise | Low per event | High (accidental clicks, shared accounts) |
| Meaning of a missing entry | Not rated | Unknown, possibly disliked |
| Typical value | Ordered scale, such as 1 to 5 | Counts or durations |
Why the difference matters
With explicit data, a rating of 1 tells you the user disliked the item. A missing rating tells you nothing, so you can ignore it and fit a model on observed entries only.
With implicit data, you only see positive actions. A user who never played a song may dislike it, or may never have heard of it. Treating every missing entry as a dislike is wrong, and treating it as ignorable discards all negative information. Implicit-feedback methods handle this by treating observed actions as confident positives and unobserved entries as weak negatives. A later chapter on matrix factorization for implicit feedback covers that approach.
Building both matrices
The next example turns raw event logs into two matrices. Ratings go straight into cells. Play counts are converted to a confidence-style value with a log transform, which stops heavy users from dominating.
import numpy as np
n_users, n_items = 4, 5
# Explicit: (user, item, rating on a 1-5 scale)
ratings = [(0, 0, 5), (0, 1, 3), (1, 0, 4), (2, 3, 1), (3, 4, 5)]
R_explicit = np.zeros((n_users, n_items))
for u, i, r in ratings:
R_explicit[u, i] = r
# Implicit: (user, item, play count)
plays = [(0, 0, 12), (0, 2, 1), (1, 0, 3), (2, 3, 40), (3, 4, 7)]
R_implicit = np.zeros((n_users, n_items))
for u, i, c in plays:
R_implicit[u, i] += c
# Compress heavy counts: log1p(0) = 0, so missing entries stay 0.
R_implicit = np.log1p(R_implicit)
# For ranking-style models, many systems keep only a binary "interacted" flag.
B = (R_implicit > 0).astype(float)
print(R_explicit)
print(np.round(R_implicit, 2))
print(B)In R_explicit, 0 means "not rated" and is never a real rating, because valid ratings start at 1. In R_implicit, 0 means "no interaction observed", which is a different statement.
Common errors
- Treating 0 as a rating. Computing a mean over a matrix with zeros pulls every average toward 0. Mask with
R > 0first. - Reading counts as preference strength without care. A user who plays a song 40 times on repeat in a loop may not like it 40 times as much. Transform or cap counts.
- Mixing signals. A purchase is stronger evidence than a click. If you combine them, assign weights deliberately.
- Ignoring exposure. An item the user never saw cannot be clicked. Missing does not mean rejected.
Exercise
A music app logs play counts per user and song. A user has 0 plays for song X. Why is it wrong to conclude the user dislikes song X, and what is the usual way to handle this in modeling?
Show answer
A zero play count has two possible causes: the user was never exposed to the song, or the user was exposed and chose not to play it. The data cannot separate them. Models for implicit feedback treat observed plays as positives with higher confidence, and treat unobserved entries as weak negatives with lower confidence, rather than as definite dislikes.