rating-score v1.0.1
rating-score
You are a web programmer. You have users. Your users rate stuff on your site. You want to put the highest-rated stuff at the top and lowest-rated at the bottom. You need some sort of “score” to sort by.
– Evan Miller, “How Not To Sort By Average Rating”
A better way to calculate ranking score to sort things on the web based on user upvotes or “stars”, using lower bound of Wilson score confidence interval for a Bernoulli parameter.
API
Table of Contents
averageToScore
Calculates the score from the average of all reviews.
This function is curried.
Parameters
- confidenceNumber
- averageRatingNumber Average review score.
- maxRatingNumber Maximum review score.
- totalReviewsNumber Total number of reviews.
Returns Number Calculated score.
starsToScore
Calculates the score from a list of review counts.
This function is curried.
Parameters
Returns Number Calculated score.
upvotesToScore
Calculates the score from the number of upvotes and downvotes.
This function is curried.
Parameters
- confidenceNumber
- upvotesNumber Number of positive reviews.
- downvotesNumber Number of negative reviews.
Returns Number Calculated score.