Users, Items, Context, and Feedback
A recommendation dataset is not merely a user-by-item table. It is a time-ordered record of what could be shown, what was shown, and what happened afterward. Those distinctions determine which questions the data can answer.
Prerequisites
Start with recommendation problems and product objectives. You should be able to state the surface's decision unit and candidate rule.
Learning goals
- Declare the grain of an interaction row.
- Separate stable identifiers from mutable user, item, and context features.
- Preserve repeated actions instead of collapsing them prematurely.
- Distinguish catalog availability, exposure, and feedback time.
One event per row
The repository fixture stores one observed event per row. user_id and item_id identify entities; timestamp orders events; event_type records an impression, click, save, completion, or explicit rating. exposed and position describe recommendation exposure. item_available_at records when the item entered the eligible catalog. split makes the teaching evaluation membership explicit.
That grain intentionally preserves repeated actions. A learner can see, click, complete, and rate the same lesson. Those are four events, not four independent preferences. Aggregation belongs after the analytical question is fixed.
Worked example: inspect the local fixture
import csv
from collections import Counter
from pathlib import Path
path = Path("tests/fixtures/recommender-systems/interactions.csv")
with path.open(encoding="utf-8", newline="") as handle:
rows = list(csv.DictReader(handle))
train_pairs = Counter(
(row["user_id"], row["item_id"])
for row in rows
if row["split"] == "train"
)
repeated = sorted(pair for pair, count in train_pairs.items() if count > 1)
print(f"rows={len(rows)} users={len({r['user_id'] for r in rows})} items={len({r['item_id'] for r in rows})}")
print(f"repeated_pairs={repeated}")
Output:
rows=24 users=5 items=7
repeated_pairs=[('u1', 'i1'), ('u2', 'i2'), ('u3', 'i3'), ('u3', 'i4')]
Context belongs to a decision time
Context can include device, locale, time, query, surface, or session state. Only use context that would exist when recommendations are produced. A completion recorded tomorrow is an outcome, not a feature available today. Item popularity computed using tomorrow's events is likewise future leakage.
Identity deserves the same care. Anonymous-device IDs, account IDs, and household IDs represent different decision units. Merging or splitting them changes histories and denominators. Collect only the identity and context needed for the declared purpose, with retention and access controls appropriate to the data.
Limitations and common mistakes
- Collapsing repeated actions can overweight or erase intensity depending on the rule.
- Treating mutable attributes as timeless can leak future state.
- An ID is not a person, and one person may map to several IDs.
- Logged items are not necessarily the complete candidate set; unavailable items and filtered items need explicit rules.
- An event timestamp may describe client occurrence, server receipt, or processing time. Choose the clock that matches the decision.
Practice
Add a hypothetical surface and request_id to the schema. State which questions each field enables, then state a retention rule. Explain why grouping only by user_id and item_id would lose exposure position and event order.
Next steps
Next, distinguish explicit and implicit feedback without converting silence into dislike.
Primary sources
Checked 2026-10-17: Google, recommendation-system overview; Google, candidate generation; and Hu, Koren, and Volinsky, “Collaborative Filtering for Implicit Feedback Datasets”.