Recommender systems
Item-Based Collaborative Filtering
Build item-item recommendation using co-interaction, adjusted similarity, temporal windows, and context-aware aggregation.
By the end you can
- Explain how item-based collaborative filtering constructs and serves item relations
- Distinguish complement, substitute, and audience-similarity relationships
- Control popularity and policy-induced co-occurrence
- Design a typed, versioned, and auditable item-relation service
Example
Substitute and complement are two different links, and someone has measured the difference
Two items that keep turning up together may be an accessory used with the first, or a rival bought instead of it. The co-occurrence count says the same thing in both cases. A 2015 study by McAuley and colleagues made that distinction the object of measurement, and supplied the definition a similarity table cannot supply for itself: "substitutes are products that can be purchased instead of each other, while complements are products that can be purchased in addition to each other."
The two are treated as link types that have to be predicted separately, and it is done at catalog scale: an Amazon catalog of 9 million products, 237 million links and 144 million reviews. Their Sceptre model averaged 94.83% accuracy on substitute links and 90.23% on complement links. Across the binary prediction tasks, accuracy ran from 85.57% to 96.76%.
Typing the relation is not editorial advice about how to phrase a widget. It is a modelling task with its own error rate. A system that never performs it has silently answered both questions with one number.
- Relation ambiguity: Co-occurrence can mean complement, substitute, bundle, comparison, or accidental joint exposure — substitute and complement links are predicted separately, at 94.83% and 90.23% average accuracy.
- Order effects: Cart placement and cross-sell modules create some of the observed co-purchases.
- Time window: Items purchased months apart may express durable ecosystem compatibility rather than one task.
- Popularity: High-volume items co-occur with almost everything.
- Availability: Stockouts hide valid item relationships and create asymmetric evidence.
Visual
From interaction graph to item candidates
Item-based retrieval settles what counts as a relation first — co-view, co-buy, sequence, wishlist, shared rating — and only aggregates for a user at the end. The steps between are where popularity, time, and task boundaries are kept from swamping the relation.
The temporal and contextual window is not a later refinement bolted onto a mature system. Amazon filed a patent on item-to-item similarity mappings on 18 September 1998. It was granted on 24 July 2001 as US Patent 6,266,649, two years before the 2003 paper. The abstract already describes recommendations served from "a previously-generated table which maps items to lists of 'similar' items". The same filing separately claims the same-task window: "In another embodiment, the recommendations are generated based on the current contents of a user's shopping cart, so that the recommendations tend to correspond to the current shopping task being performed by the user."
The precomputed table and the contextual window were written into one filing. They are two halves of one design, not a first version and a fix.
Choose relation events
Define co-view, co-buy, sequence, wishlist, or shared-rating evidence.
Control exposure and popularity
Normalize counts and consider expected co-occurrence under item frequency.
Estimate item similarity
Use cosine, adjusted cosine, lift, log-likelihood, or learned embeddings.
Apply temporal and contextual windows
Separate same-task relations from long-term ecosystem relations.
Aggregate for a user
Combine recent seed items, relation type, eligibility, and repetition controls.
Item-based filtering transfers evidence through item relations
Similar interaction patterns make two items neighbors, and the recommender serves the neighbors of items already associated with the user. A 2001 paper by Sarwar and colleagues said why that axis is the practical one: "As we discussed earlier, item-based similarity is more static and allows us to precompute the item neighborhood."
The numbers behind that sentence come from MovieLens: 943 users by 1,682 movies, 100,000 ratings, sparsity level 0.9369. Adjusted cosine beat plain cosine and correlation, and was kept for the rest of the paper. Item-item reached MAE 0.726 against user-user's 0.732 at neighbourhood size 60. Accuracy was not the argument. What the precomputation costs was. A model retaining only 50 similar items per row reached 98.3% of the full scheme's accuracy while storing 3% of the items. At model size 25 it held 96% of accuracy on 1.9% of items. A table that small can be built ahead of time and read at request time. That is the whole proposition.
The relation still depends on how the event was defined. Co-view, co-buy, sequence adjacency, repeated substitution, and shared audience each build a different graph. They should not be collapsed into one undifferentiated similarity table.
Whichever event you count as a relation becomes the question the recommender answers, long after anyone remembers making that choice.
Item relations are valuable retrieval primitives
Use item-item candidates alongside popularity, content, graph, and two-tower sources. That multi-source pool is not a whiteboard ideal. It is published architecture. The 2016 paper on YouTube's recommender lays out the funnel: candidate generation winnows a corpus of millions to hundreds, and ranking scores those few hundred with hundreds of features and returns dozens. Its Figure 2 shows "other candidate sources" entering the ranker alongside the learned generator. The authors state in print why the ranker has to reconcile them: "Ranking is also crucial for ensembling different candidate sources whose scores are not directly comparable." The same paper records that natural consumption produces very asymmetric co-watch probabilities between items. Even one source's own evidence about a pair depends on which item you started from.
If the scores arriving from different sources are not comparable, an unlabelled pool cannot be audited at all. Source labels make it possible to measure marginal recall, and to detect when one relation table dominates the candidate pool. For explanations, reveal a defensible relation: compatible accessory, similar topic, often considered together. Avoid claiming that collective behavior proves quality or suitability for the individual.
Without source labels, one dominant relation table looks like a healthy candidate pool right up to the point where nothing else can surface.
Example
Item-item modeling traps
Raw count domination corrupts the whole table at once, since a popular item ends up related to everything. That failure was described for word pairs long before anyone applied it to catalogs. The log-likelihood-ratio co-occurrence score this lesson names among its similarity measures comes from a 1993 paper by Ted Dunning. On a 31,777-word financial corpus he analysed 2,693 bigrams. Of those, 2,682 fell outside the range where the normal chi-squared test is valid. The 11 that did qualify were exactly the ones you would not want: "It is notable that all of these bigrams contain the word the, which is the most common word in English." At the other end, the chi-squared ranking's top entries were dominated by pairs occurring exactly once. The naive association statistic survives for the most frequent token and rewards accidents. That is raw count domination, stated as a measurement.
Policy-induced co-occurrence has been simulated end to end. A 2018 study by Chaney and colleagues names the mechanism at the outset: "These systems are often evaluated or trained with data from users already exposed to algorithmic recommendations; this creates a pernicious feedback loop." They simulated communities of 100 users over 1,000 time intervals, with ten new items introduced per interval, each simulation repeated with ten random seeds and averaged. With repeated retraining on the system's own output, every non-random recommender homogenised user behaviour beyond the level ideal utility required. Popularity-based recommendation homogenised users the most globally. The users with lower relative utility were the more homogenised ones. The two traps meet there: the popularity that corrupts the table is also what the loop amplifies.
Seed contamination corrupts one user at a time. A single mistaken click can carry a chain of irrelevant recommendations for weeks.
- Raw count domination: Popular items appear related to every category — of Dunning's 2,693 bigrams, 2,682 fell outside the range where the naive test is valid, and the 11 that qualified all contained the most common word in English.
- Policy-induced co-occurrence: Existing widgets manufacture the relation later used as evidence; in Chaney and colleagues' simulation every non-random recommender homogenised behaviour beyond what ideal utility required.
- Relation type collapse: Substitution and complementarity receive the same explanation and re-ranking, though the 2015 catalog study predicts them as two separate link types with separate accuracies.
- Stale graph: New versions, prices, or inventory make old relations unsafe.
- Seed contamination: A mistaken click creates an entire chain of irrelevant recommendations.
Analogy
A map of roads, not a dictionary of places
Journeys map a city's roads, not its places. Two locations may be linked because people visit both, because one replaces the other, or because a transit hub sits between them.
Item-item data reveals routes in exactly that sense. That is why one similarity table cannot answer both what goes with this and what competes with this. Those are the two questions that needed separate predictors, and separate accuracies.
Behavioral proximity needs a named relation before it becomes a useful recommendation.
Steps
Create a typed item-relation service
An item relation without stated semantics is a number without a unit. The service fixes the semantics first, then normalizes frequency, validates examples, versions the table, and serves it behind safeguards.
Each step has a published precedent to borrow from. Normalization is where Dunning's log-likelihood ratio belongs, and the reason it exists is that the naive statistic left 2,682 of 2,693 pairs outside its valid range. Versioning is affordable because the table can be truncated: 98.3% of the full scheme's accuracy survived on 3% of the items. Serving inherits the YouTube problem. Scores from different candidate sources are not directly comparable, so the ranker, not the relation table, is where they are reconciled.
1. Define relation semantics
State which event pattern supports each relation type.
2. Normalize frequency
Use lift, shrinkage, or expected-count controls for popular items.
3. Validate examples
Inspect head, tail, new, seasonal, and policy-affected item pairs.
4. Version and refresh
Track catalog changes, windows, and relation-service releases.
5. Serve with safeguards
Apply compatibility, diversity, eligibility, and user-level feedback.
Key idea
The relation gate
Promote an item relation only when its event semantics, normalization, freshness, and user-facing explanation remain valid. Semantics means saying which of the two link types, substitute or complement, this pair belongs to. Freshness means measuring your cadence against Amazon's: a table rebuilt for every product on the site, every day. That is the standard, not an aspiration.
A relation that passed the gate last month is not still passing it; the cache does not re-ask, so something else has to.
Key takeaways
- Item-based filtering is powerful because relations can be cached — 98.3% of the full scheme's accuracy survived on 3% of the items — and the same cache makes stale mistakes easy to scale.
- Similar interaction patterns make two items neighbors, and the recommender serves the neighbors of items already associated with the user; on MovieLens that gave MAE 0.726 against user-user's 0.732 at neighbourhood size 60.
- Item similarity describes behavioral association under a policy. Training on data from users already exposed to recommendations is "a pernicious feedback loop", which is not the same thing as semantic equivalence.
- Which event you count as a relation decides the question the recommender answers: substitutes and complements are separate link types, predicted at 94.83% and 90.23% average accuracy.
- Raw count domination remains a practical risk: popular items appear related to every category, and of Dunning's 2,693 bigrams the 11 that survived the naive test all contained the most common word in English.
- Serving neighbor lists safely means checking compatibility and eligibility, adding diversity, and letting user-level feedback override a relation the cache keeps repeating — and reconciling sources at the ranker, since their scores are not directly comparable.