All problems
Popularity Bias Share
Problem
Compute the popularity bias share: the fraction of recommended item ids that appear in the popular item list. Empty recommendations return 0.0.
Hint
High popularity share can starve the long tail of exposure.
Test cases
case 1
in: [[1,2,3,4],[1,3]]
expected: 0.5
case 2
in: [[5,6],[1,2]]
expected: 0
case 3
in: [[1,1,1],[1]]
expected: 1
case 4
in: [[],[1]]
expected: 0
Starter codePython
def popularity_bias_share(recommended_ids, popular_ids):
# Your code here
pass4 test cases · run your code against them in the editor