Catalog Coverage
Catalog Coverage
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.
Formula
coverage=∣catalog∣∣unique recommended items∣Examples
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.
Hint 1
Use a set to collect all unique items from every recommendation list. The set automatically handles deduplication across users.
Hint 2
Loop through each user's recommendation list and add all items to the set. Then divide the set size by n_items.
Requirements
- Collect all unique items across all recommendation lists
- Divide the count of unique items by the total catalog size
- Return 0.0 if the catalog size is 0
- Return a float between 0.0 and 1.0
Constraints
- Each recommendation list contains item IDs (integers)
- n_items >= 0
- Return a float
- Time limit: 300 ms
Try Similar Problems
Log in to take notes on this problem
Accepts: array
Accepts: number
Catalog Coverage
Catalog Coverage
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.
Formula
coverage=∣catalog∣∣unique recommended items∣Examples
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.
Hint 1
Use a set to collect all unique items from every recommendation list. The set automatically handles deduplication across users.
Hint 2
Loop through each user's recommendation list and add all items to the set. Then divide the set size by n_items.
Requirements
- Collect all unique items across all recommendation lists
- Divide the count of unique items by the total catalog size
- Return 0.0 if the catalog size is 0
- Return a float between 0.0 and 1.0
Constraints
- Each recommendation list contains item IDs (integers)
- n_items >= 0
- Return a float
- Time limit: 300 ms
Try Similar Problems
Log in to take notes on this problem
Accepts: array
Accepts: number