MetaCyberGuru Academy
A recommender chooses what receives attention. Accuracy matters, but so do coverage, diversity, freshness, safety and whether the feedback loop repeatedly amplifies a narrow slice of content.
Define relevance and exposure separately
You will build a content-similarity baseline and learn how collaborative methods, matrix factorization and implicit feedback change the evidence.
- Distinguish content-based, neighbourhood and latent-factor recommenders.
- Handle explicit ratings and implicit signals without treating clicks as pure preference.
- Evaluate ranking with temporal splits and leave feedback collection realistic.
- Measure coverage, diversity and popularity bias beside relevance.
Observed behaviour is shaped by earlier recommendations
Content-based methods compare item attributes and a user’s previous items. They can explain similarity but may overspecialize. Collaborative filtering uses patterns across users and items. It can discover unexpected relationships but struggles with new users and new items.
Matrix factorization represents users and items with latent vectors whose dot product estimates affinity. These dimensions are fitted patterns, not guaranteed human concepts. Regularization helps prevent sparse users or popular items from being memorized.
Clicks, watch time and purchases are implicit feedback. Non-interaction does not necessarily mean dislike because the user may never have seen the item. Training data needs exposure information or careful negative sampling.
Random splitting can leak future interactions and make familiar items appear easy. A chronological split asks whether past behaviour recommends later items. Prevent the same event and its derived aggregates from crossing the cutoff.
Precision at k and recall at k measure ranked relevance. Add catalogue coverage, intra-list diversity, novelty and subgroup exposure. Online experiments need guardrails and informed organisational review because optimization changes what users see.
Build a content-similarity baseline
The example uses item tags and cosine similarity. It recommends items similar to one seed item while excluding the seed itself.
Install the lesson dependencies
python -m pip install pandas scikit-learnRank items by tag overlap
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
items = pd.DataFrame({
"item": ["A", "B", "C", "D"],
"tags": [
"python data beginner",
"python machine-learning intermediate",
"design typography beginner",
"data sql intermediate",
],
})
matrix = TfidfVectorizer(token_pattern=r"(?u)\b[\w-]+\b").fit_transform(items["tags"])
seed_index = 0
scores = cosine_similarity(matrix[seed_index], matrix).ravel()
ranking = sorted(
((items.loc[i, "item"], float(scores[i])) for i in range(len(items)) if i != seed_index),
key=lambda pair: pair[1], reverse=True
)
print("seed:", items.loc[seed_index, "item"])
for item, score in ranking:
print(item, round(score, 3))Expected ranking shape
seed: A
B <positive similarity from python>
D <positive similarity from data>
C 0.281The tag vocabulary controls every explanation. Item C has a small overlap through the shared word beginner. A missing, broad or misleading tag changes recommendations, so content metadata is part of model quality.
Recommendation failures to simulate
Evaluate the system under empty histories and catalogue change, not only active users with many interactions.
- A new user needs a transparent fallback such as popular, recent or selected starter items.
- A popularity-only fallback can starve new items of exposure.
- Using clicks as negatives for unseen items confuses no exposure with dislike.
- Optimizing engagement alone can reduce variety or amplify harmful material.
Create an offline recommendation evaluation
Construct synthetic timestamped interactions and hide each user’s latest eligible item.
- Compare popularity and content baselines.
- Report precision at k, user coverage and catalogue coverage.
- Create cold-user and cold-item slices.
- Document filtering, safety and fallback rules before ranking.
Recommender evidence
- Temporal evaluation table.
- Coverage and diversity report.
- Example recommendation with evidence and fallback behaviour.
Knowledge check
Official references and further reading
- scikit-learn cosine similarity (Official similarity implementation)
- scikit-learn TF-IDF (Official sparse text representation)
Review note for Recommender Systems: Collaborative and Content-Based Methods: recheck the linked documentation after a dependency changes the relevant API, metric or modelling assumption, then record the tested version beside your result.
Save your place
Completion is stored only in this browser on this device.
Share this page
Share this page with the people who will use it next.
Discussion
No comments yet. Add the first useful question or observation.
You must log in to post a comment.