I want to turn reviews of up to 5 stars and the number of reviews into upvotes. What's a good algorithm for doing this?

A venue with 10 reviews total with a 5-star average rating should obviously get more upvotes than a venue with 10 reviews total with a 3-star average rating. Also, a venue with 60 ratings and a 4-star rating should probably get more upvotes than the one with 10 reviews and a 5-star rating.

I need this rating to be based off of the total number of reviews and the average star rating, but I would also like the number to stay below a variable number (for example, say upvotes stay below 100, but I can also plug in 200 and it would stay below 200).

  • $\begingroup$ An upvote is something a person does, so presumably an upvote is a translation of an individual rating. There seem to be only two reasonable choice: either 5-star, or 4- and 5-star, ratings map to an upvote. Is there more to it than this? $\endgroup$ – Sean Owen Mar 2 '15 at 8:55
  • 1
    $\begingroup$ Might be useful: Deriving the Reddit Formula $\endgroup$ – Emre Jul 23 '15 at 17:36

My recommendation would be to explore some statistical approach to represent the reviews/rating pair as significance. For example, to translate the [# reviews, rating] into some test statistic type model, such as Student's t for starters.

Considering your example numbers, some approaches can be:


>>> 5/(1/sqrt(10))
>>> 3/(1/sqrt(10))
>>> 4/(1/sqrt(60))
>>> 5/(1/sqrt(10))

2) Or, diving deeper into stats,:

>>> (5-3)/(sqrt(1/10+1/10))
>>> (4-5)/(sqrt(1/60+1/10))

(you will need to do some work on the alpha level to get at the significance in ex 2 above)

You can see how these work out for you; if too basic/too many inaccurate assumptions/some other filtering that you need more resolution in your model/etc., you can explore ways to better represent:

  • the sample standard deviation (assumed to be 1 in my examples above), or
  • the distribution (assumed Gaussian in examples above), or
  • the appropriate statistical test (plow through Wikipedia), or
  • etc

Point is you can continuously refine your model, depending how much resolution you need. Only you can make that call. Hope this helps!


It is an old question, but I want to suggest a different approach than the other answers.

Using a sentiment analysis on reviews

Let's say that the data we have are:

  • 5-stars rating (zero to five)
  • N number of reviews for each entry

We use a sentiment analysis model to calculate the "mood" of each review. The result would be "negative", "neutral" and "positive", based on the content of the review.

You can read more about sentiment analysis and find some APIs in this Quora's question.

Then, you will use a multiplier for each mood.

  • 0: negative mood
  • 0.5: neutral mood
  • 1: positive mood

As a result, you can add the review score like multiplier*5 for each review in your dataset. For example in pseudocode,

var current_5_star;
for each review in this_entry:
    multiplier = calc_sentiment(review)
    current_5_star += multiplier * 5

If you want to improve further the model, you can use the total number of reviews on your dataset to normalize the multiplier.

To sum up, you do not only use the number of reviews per se, but also the content of them to evaluate the exact impact of it in the rating score.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.