TF-IDF (Term Frequency – Inverse Document Frequency)
TF-IDF is a weighting method that adjusts the co-occurrence score to avoid the dominance of overly generic products (e.g., batteries, gift cards). It’s borrowed from information retrieval (used in search engines).
How it is calculated
For each pair of products i and j, the frequency of co-occurrence (TF) is weighted by an inverse frequency term (IDF):

Where:
TF(i,j) = co-occurrence frequency between products
iandjN = total number of products
n_j = number of distinct products co-occurring with product
j
This down-weights products that appear in too many contexts, giving more weight to specific, relevant relationships.
Example
Without TF-IDF: “Book” → “Gift card” (appears in every basket).
With TF-IDF: “Book” → “Next volume in the same series” (more relevant association).
Key takeaways
Increases recommendation relevance and diversity.
Surfaces niche or underexposed products.
Reduces noise from universally popular items.
Last updated
Was this helpful?

