Sub topic 15
Popularity Bias and Feedback Loops
This chapter assumes you can compute precision@k and recall@k, that you know how a user-item matrix is built, and that you have seen a trained recommender produce top-N lists. It covers why those lists lean toward popular items, how that lean grows over time, and what you can do about it.
What popularity bias is
Interaction data is heavily skewed. A small set of items collects most of the interactions, and a long tail of items collects very few. Collaborative filtering learns from counts of behavior, so it inherits that skew.
Popularity bias is the tendency of a recommender to suggest popular items more often than their true match to the user justifies. It shows up in three common ways:
- Neighborhood methods find more evidence for popular items. Many neighbors have rated them, so similarity-weighted averages are stable and often high.
- Matrix factorization fits the observed entries. Popular items appear in many training rows, so their factors get many updates and large, confident scores. Rare items get few updates, and regularization pulls their factors toward zero.
- Ranking metrics reward it. If most held-out interactions are with popular items, a recommender that always returns the most popular items scores well on precision@k.
That last point matters. A popularity baseline is often hard to beat, so a model that only matches it adds little value.
Measuring the skew
Before you fix anything, measure it. Two simple checks are the share of interactions held by the top items and the share of recommendations that come from them.
import numpy as np
# Rows are users, columns are items. 0 means "not rated".
R = np.array([
[5, 3, 0, 1],
[4, 0, 0, 1],
[1, 1, 0, 5],
[1, 0, 0, 4],
[0, 1, 5, 4],
], dtype=float)
counts = (R > 0).sum(axis=0)
order = np.argsort(counts)[::-1]
print("interactions per item:", counts)
print("items by popularity:", order)
def recommendation_share(top_n_lists, counts, head_size):
head = set(np.argsort(counts)[::-1][:head_size])
total = sum(len(lst) for lst in top_n_lists)
in_head = sum(1 for lst in top_n_lists for i in lst if i in head)
return in_head / total
lists = [[3, 0], [3, 1], [0, 3], [3, 0], [3, 1]]
print(recommendation_share(lists, counts, head_size=2))If the top 20 percent of items hold 80 percent of interactions but receive 95 percent of recommendations, the model amplifies the skew. If the shares match, it mostly reflects it.
Other useful measures:
- Coverage is the fraction of the catalog that appears in at least one user's top-N list. Low coverage means most items never get shown.
- Average popularity of recommended items compared with the average popularity of items users actually consumed.
- Gini index of recommendation counts across items. Higher values mean exposure is concentrated in fewer items.
Why bias is not always wrong
Popular items are often popular for good reasons. A recommender that surfaces them is correct for many users. The problem appears when the system shows popular items because they are popular, not because they fit. That distinction is hard to see in offline metrics, which is why you check coverage and per-user results alongside precision@k.
Feedback loops
A feedback loop forms when a model's output changes the data it is later trained on. Recommendation systems are prone to this because users mostly interact with what they are shown.
Here is the mechanism step by step:
- The model ranks item A above item B, slightly and perhaps by chance.
- Item A is shown more often, so it gets more clicks.
- The next training set contains more interactions for A and fewer for B.
- The retrained model ranks A even higher.
The data does not show that users prefer A. It shows that users could only click what they saw. This is called exposure bias, and it is a form of selection bias: missing interactions are not missing at random. For implicit feedback, a missing interaction can mean "disliked", "never saw it", or "saw it and was indifferent", and the loop makes "never saw it" more common for tail items.
Related effects include:
- Rich-get-richer dynamics. Early leaders in popularity keep their lead.
- Filter bubbles. A user's history narrows their recommendations, which narrows their future history.
- Homogenization. Many users receive similar lists, so their behavior converges and the data loses variety.
Simulating the loop
A small simulation makes the effect visible. Each round, the system recommends the top items by current counts, users click shown items with equal underlying probability, and counts are updated.
import numpy as np
def simulate(n_items=10, n_rounds=50, n_users=200, top_n=3, seed=0):
rng = np.random.default_rng(seed)
counts = np.ones(n_items) # every item starts equal
true_click_prob = 0.3 # same for all items
for _ in range(n_rounds):
shown = np.argsort(counts + rng.random(n_items) * 0.01)[::-1][:top_n]
clicks = rng.binomial(n_users, true_click_prob, size=top_n)
counts[shown] += clicks
return counts
counts = simulate()
print(np.round(counts / counts.sum(), 3))Every item has the same true appeal, yet the printed shares concentrate on the three items that won the early tie-breaks. The other seven never get shown after the first round, so their counts do not grow. The model "learned" a preference that was created entirely by its own exposure.
Mitigations
No single fix removes the problem. Most systems combine several, applied at different stages.
| Stage | Technique | What it does | Cost |
|---|---|---|---|
| Data | Log what was shown, not just what was clicked | Lets you model exposure explicitly | Extra logging and storage |
| Data | Randomized exposure for a small traffic slice | Gives unbiased interaction data | Short-term loss of relevance |
| Training | Inverse propensity weighting | Upweights interactions that were unlikely to be shown | High variance when propensities are small |
| Training | Popularity-aware loss or negative sampling | Samples popular items less often as negatives | Needs tuning |
| Ranking | Re-ranking for diversity or novelty | Swaps some head items for tail items after scoring | May lower accuracy metrics |
| Ranking | Exploration (epsilon-greedy, bandits) | Shows uncertain items to learn about them | Some users see weaker results |
| Evaluation | Report coverage, novelty, and popularity-stratified metrics | Makes the bias visible | None beyond effort |
A simple popularity penalty
A cheap re-ranking step subtracts a term proportional to log popularity from each score before taking the top N.
import numpy as np
def rerank(scores, counts, alpha=0.5, n=3):
penalty = alpha * np.log1p(counts)
adjusted = scores - penalty
return np.argsort(adjusted)[::-1][:n]
scores = np.array([4.8, 4.5, 4.4, 4.3, 4.2])
counts = np.array([900, 40, 15, 8, 3])
print(rerank(scores, counts, alpha=0.0))
print(rerank(scores, counts, alpha=0.3))With alpha=0.0 the list is just the model's ranking. With a positive alpha, the item with 900 interactions drops down the list. Choose alpha by checking both accuracy and coverage on validation data, because the two trade off.
Inverse propensity weighting
If you know or can estimate the probability p(u, i) that item i was shown to user u, weight each observed interaction by 1 / p(u, i) in the training loss. An interaction with an item that was rarely shown counts for more. The weights can be large, so clip them (for example to a maximum of 10 to 20) to control variance. The estimate of p is itself a model and can be wrong.
Evaluation caveats
Offline evaluation uses logged data that was produced by an earlier recommender, so it is already affected by exposure bias. A new model that surfaces different items is penalized, because the held-out data holds few interactions with items the old system never showed. This means:
- A model that reduces popularity bias can look worse offline while being better online.
- Gains from a popularity-heavy model can be partly an artifact of the logs.
- The reliable check is an online experiment, or an offline set collected under randomized exposure.
Common errors
- Treating a missing interaction as a negative label without asking whether the item was ever shown.
- Retraining on logs from the current model with no exploration, which locks in the current ranking.
- Tuning only for accuracy and noticing the lack of diversity after launch.
- Applying a popularity penalty so large that irrelevant tail items fill the lists.
- Measuring diversity globally and missing that each individual user still sees a narrow slice.
Exercise
A team's recommender has 0.31 precision@10, but only 4 percent of the catalog appears in any top-10 list, and the top 5 percent of items receive 70 percent of recommendations. Name the problem, one metric that quantifies it beyond what the team reported, and two mitigations at different pipeline stages.
Show answer
The problem is popularity bias, reinforced by a feedback loop if the model is retrained on its own logged exposure. Catalog coverage (4 percent) already shows it, and you can add the Gini index of recommendation counts or recall stratified by head and tail items. Mitigations at different stages: a popularity penalty or diversity re-ranking at ranking time, and logging shown items with a small randomized-exposure slice (or inverse propensity weighting) at the data and training stage.
Exercise
In the simulation above, all items have the same true click probability, yet shares concentrate on a few items. Explain why, and say which single change to the loop would let the other items recover.
Show answer
Only the items shown in a round can collect clicks. The top items by count are shown every round, so their counts keep growing while the others stay flat. Adding exploration, for example showing a random item or an item chosen by an uncertainty bonus in each round, gives unshown items a chance to collect clicks and shows that their appeal matches the others.