Novelty measures how surprising or unexpected recommendations are to a user. It is based on the idea that recommending popular items everyone has seen is not very useful, while recommending lesser-known items provides more value. Novelty is computed using self-information: the less popular an item, the more novel it is.
Given a list of recommended item indices, their interaction counts, and the total number of users, compute the average novelty score.
where counti is the number of users who interacted with item i, and N is the total number of users.
Input:
recommendations = [0, 1], item_counts = [100, 100], n_users = 100
Output:
0.0
Both items were seen by all 100 users. Popularity = 1.0. -log2(1.0) = 0. These items have zero novelty.
Input:
recommendations = [0, 1], item_counts = [1, 1], n_users = 100
Output:
6.6439
Both items were seen by only 1 user. Popularity = 0.01. -log2(0.01) = 6.6439. Very novel items.
For each recommended item, compute popularity = item_counts[item] / n_users. Then compute -math.log2(popularity). Average over all items.
Be careful: use log base 2 (math.log2), not natural log (math.log). Also handle the edge case where the recommendation list is empty.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number
Novelty measures how surprising or unexpected recommendations are to a user. It is based on the idea that recommending popular items everyone has seen is not very useful, while recommending lesser-known items provides more value. Novelty is computed using self-information: the less popular an item, the more novel it is.
Given a list of recommended item indices, their interaction counts, and the total number of users, compute the average novelty score.
where counti is the number of users who interacted with item i, and N is the total number of users.
Input:
recommendations = [0, 1], item_counts = [100, 100], n_users = 100
Output:
0.0
Both items were seen by all 100 users. Popularity = 1.0. -log2(1.0) = 0. These items have zero novelty.
Input:
recommendations = [0, 1], item_counts = [1, 1], n_users = 100
Output:
6.6439
Both items were seen by only 1 user. Popularity = 0.01. -log2(0.01) = 6.6439. Very novel items.
For each recommended item, compute popularity = item_counts[item] / n_users. Then compute -math.log2(popularity). Average over all items.
Be careful: use log base 2 (math.log2), not natural log (math.log). Also handle the edge case where the recommendation list is empty.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: number