liveBook · Manning

Item-based collaborative filtering

As explained in AI Recommender Systems

A collaborative-filtering technique that recommends items based on similarities among items inferred from user interactions.

Item-based collaborative filtering recommends items by finding other items consumed by the same users. Instead of comparing users, it compares columns in a user–item interaction matrix, exposing behavioral relationships that item metadata may miss. section 1.3.2 section 2.6

A simple implementation follows this path:

  • Represent clicks, purchases, ratings, or consumption as a user–item matrix. section 1.3.2
  • Select a seed item and compute its similarity to every other item with a dot product over user interactions. section 1.3.2
  • Remove the seed item, sort the similarity scores, and return the highest-ranked items. section 1.3.2
  • Place the result in retrieval, filtering, scoring, and ordering stages when building a broader recommender pipeline. section 2.6

From a comic to related items

If Asterix and Superman were consumed by 21 users, their co-consumption contributes to item similarity. Querying Superman can therefore return Lucky Luke and Tintin, reflecting behavioral overlap rather than shared metadata. section 1.3.2

More like this

For Toy Story (1995), item-based recommendations include Toy Story 2, Aladdin, Monsters, Inc., The Lion King, and A Bug's Life. The learned connections come from users who enjoyed the seed movie. section 3.3.7

Listing 1.7 Item-based Collaborative filtering .
def find_similar_items(matrix: np.array, item_id: int, top_n: int = 3):
    item_sim = np.dot(matrix.T[item_id], matrix.T)  #A
    item_sim[item_id] = 0  #B
    most_similar_items = np.argsort(item_sim)[::-1][:top_n]  #C
    return most_similar_items.tolist()

The listing shows the minimal item-based calculation: transpose the interaction matrix, compute similarity for one item, exclude that item, and select the top results. section 1.3.2

How AI Recommender Systems covers it

How deep it goes
Explains matrix-based similarity and ranked retrieval with code, but stops short of detailed similarity normalization or production optimization.
Examples
Uses co-consumed comics, a user–item matrix, and Toy Story movie recommendations to demonstrate item similarity.
What it assumes
Assumes interaction data arranged as a user–item matrix and distinguishes behavioral signals from item metadata.
What you can do after
Build it from scratch by computing item similarities from interaction matrices and returning ranked neighbors for a seed item.
How it connects
Connects collaborative filtering with user-based collaborative filtering, content-based recommendations, ItemKNN, and recommender-system retrieval.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Recommender Systems. The section links point to the parts of the book it draws on.