Catalog coverage measures the fraction of available items that a recommender system actually recommends across all users. A system that always recommends the same popular items will have low coverage, while one that surfaces diverse items from the catalog will have high coverage. This metric is important for evaluating recommendation diversity and detecting popularity bias.
Given a list of recommendation lists (one per user) and the total number of items in the catalog, compute the catalog coverage as the fraction of unique recommended items over the catalog size.
Input:
recommendations = [[1,2,3],[2,3,4],[4,5,6]], n_items = 10
Output:
0.6
Unique items: {1,2,3,4,5,6} = 6 items. Coverage = 6/10 = 0.6.
Input:
recommendations = [[1,2],[1,2],[1,2]], n_items = 5
Output:
0.4
All users get the same 2 items. Coverage = 2/5 = 0.4. This indicates high popularity bias.
Use a set to collect all unique items from every recommendation list. The set automatically handles deduplication across users.
Loop through each user's recommendation list and add all items to the set. Then divide the set size by n_items.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Catalog coverage measures the fraction of available items that a recommender system actually recommends across all users. A system that always recommends the same popular items will have low coverage, while one that surfaces diverse items from the catalog will have high coverage. This metric is important for evaluating recommendation diversity and detecting popularity bias.
Given a list of recommendation lists (one per user) and the total number of items in the catalog, compute the catalog coverage as the fraction of unique recommended items over the catalog size.
Input:
recommendations = [[1,2,3],[2,3,4],[4,5,6]], n_items = 10
Output:
0.6
Unique items: {1,2,3,4,5,6} = 6 items. Coverage = 6/10 = 0.6.
Input:
recommendations = [[1,2],[1,2],[1,2]], n_items = 5
Output:
0.4
All users get the same 2 items. Coverage = 2/5 = 0.4. This indicates high popularity bias.
Use a set to collect all unique items from every recommendation list. The set automatically handles deduplication across users.
Loop through each user's recommendation list and add all items to the set. Then divide the set size by n_items.
Sign in to take notes on this problem
Accepts: array
Accepts: number