TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

Popularity Ranking

Recommender Systems
Easy

A raw average rating can overvalue an item that has very few votes. A weighted rating blends each item's average with a global mean, with the vote count controlling how strongly the item's own rating is trusted.

WR⁡=vv+mR+mv+mC\operatorname{WR} = \frac{v}{v+m}R + \frac{m}{v+m}CWR=v+mv​R+v+mm​C

Here, R is the item's average rating, v is its vote count, m is min_votes, and C is global_mean. Each item is supplied as [average_rating, vote_count]. Return the weighted ratings in the original item order.

Loading visualization...

Examples

Input: items = [[8.5, 1000], [9.2, 50], [7, 5000]], min_votes = 100, global_mean = 7.5

Output: [8.409091, 8.066667, 7.009804]

Explanation: Items with many votes remain close to their own averages, while the 50-vote item is pulled more strongly toward 7.5.

Input: items = [[10, 1]], min_votes = 100, global_mean = 5

Output: [5.049505]

Hint 1

For each item, use vote_count + min_votes as the shared denominator.

Hint 2

Compute the item-rating contribution and global-mean contribution separately, then add them.

Requirements

  • Apply the weighted-rating formula independently to every item.
  • Preserve the original item order.
  • Return one float for each item.

Constraints

  • items is a list of [average_rating, vote_count] pairs.
  • Vote counts are nonnegative.
  • min_votes is positive.
  • Time limit: 300 ms.
Try Similar Problems
Baseline PredictorTop K RecommendationsNovelty ScoreCatalog CoverageHit Rate At K

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: number

Accepts: number

You must run your code first.
PrevNext

Popularity Ranking

Recommender Systems
Easy

A raw average rating can overvalue an item that has very few votes. A weighted rating blends each item's average with a global mean, with the vote count controlling how strongly the item's own rating is trusted.

WR⁡=vv+mR+mv+mC\operatorname{WR} = \frac{v}{v+m}R + \frac{m}{v+m}CWR=v+mv​R+v+mm​C

Here, R is the item's average rating, v is its vote count, m is min_votes, and C is global_mean. Each item is supplied as [average_rating, vote_count]. Return the weighted ratings in the original item order.

Loading visualization...

Examples

Input: items = [[8.5, 1000], [9.2, 50], [7, 5000]], min_votes = 100, global_mean = 7.5

Output: [8.409091, 8.066667, 7.009804]

Explanation: Items with many votes remain close to their own averages, while the 50-vote item is pulled more strongly toward 7.5.

Input: items = [[10, 1]], min_votes = 100, global_mean = 5

Output: [5.049505]

Hint 1

For each item, use vote_count + min_votes as the shared denominator.

Hint 2

Compute the item-rating contribution and global-mean contribution separately, then add them.

Requirements

  • Apply the weighted-rating formula independently to every item.
  • Preserve the original item order.
  • Return one float for each item.

Constraints

  • items is a list of [average_rating, vote_count] pairs.
  • Vote counts are nonnegative.
  • min_votes is positive.
  • Time limit: 300 ms.
Try Similar Problems
Baseline PredictorTop K RecommendationsNovelty ScoreCatalog CoverageHit Rate At K

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: number

Accepts: number

You must run your code first.