Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you build a ratings implementation?

We have need for a "rating" system in a project we are working on, similar to the one in SO. However, in ours there are multiple entities that need to be "tagged" with a vote up (only up, never down, like an increment). Sometimes we will need to show all of the entities in order of what is rated highest, regardless of entity type, basically mixing the result sets, I guess. What data structures / algorithms do you use to implement this so that is flexible and still scalable?

like image 869
Sam McAfee Avatar asked Aug 29 '08 17:08

Sam McAfee


People also ask

How effective are rating systems?

In fact, 80% of parents agree that the rating system is accurate in its classification of movies. While they might not be as familiar with the rating descriptors that accompany the ratings, parents find them just as helpful, and even slightly more accurate in reflecting the content of a movie.

Why is a rating system important?

Ratings and reviews create transparency and accountability And when reviews and ratings are easily visible to anyone in the marketplace, this transparency strengthens the accountability created by this system. Ratings and reviews allow people and businesses to build or break trust over time.

What are ratings and reviews?

Ratings and reviews allow customers to share their experience with a product or service, and give it an overall star rating. Shoppers rely on this content to make more informed purchase decisions.


1 Answers

Since reddit's ranking algorithm rocks, it makes very much sense to have a look at it, if not copy it:


Given the time the entry was posted A and the time of 7:46:43 a.m. December 8, 2005 B we have ts as their difference in seconds:

ts = A - B

and x as the difference between the number of up votes U and the number of down votes D:

x = U - D

Where

y = 1 if x > 0
y = 0 if x = 0
y = -1 if x < 0

and z as the maximal value of the absolute value of x and 1:

z = |x| if |x| >= 1
z = 1 if |x| < 1

we have the rating as a function ƒ(ts, y, z):

ƒ(ts, y, z) = log10 z + (y • ts)/45000


like image 126
Serhat Ozgel Avatar answered Oct 22 '22 14:10

Serhat Ozgel