Page 1 of 1
A perfect ORDER BY rating
Posted: Thu Jan 15, 2009 6:29 pm
by kaisellgren
Hello,
I'm currently developing a showcase where I want this option order by rating. However, I'm not happy with the way most sites work. For example, think about having a 5 stars rating system, if I rate something 5 stars and I am the only one who has rated it, then it's already in the top 1! No that's not good, we need something to add more weight to items that have more votes.
Currently I'm doing a thumbs up and down system. And I am trying to figure out a good algorithm for this. I started playing with PHP, try running this:
Code: Select all
$values = array(array(5,3),array(5,0),array(10,5),array(15,13));
function get($valuesarray)
{
global $method;
$up = $valuesarray[0];
$down = $valuesarray[1];
return (($up-$down)*log($up+$down,3));;
}
foreach ($values as $array)
{
echo 'Up: '.$array[0].'<br />Down: '.$array[1].'<br />Order: '.number_format(get($array),2,'.',' ').'<br /><br />';
}
You get something like:
Up: 5
Down: 3
Order: 3.79
Up: 5
Down: 0
Order: 7.32
Up: 10
Down: 5
Order: 12.32
Up: 15
Down: 13
Order: 6.07
Up 5, Down 0 has a great rate, but only 5 rates so it loses against 10/5.
Are there any algorithms for these kind of situation where we are trying to make a realistic "order by rating" feature?
In 5-star rating system, It's obvious that something that has rate of 4.95 and 1000 votes should rank higher than rate of 4.96 with e.g. 600 votes.
Re: A perfect ORDER BY rating
Posted: Thu Jan 15, 2009 7:11 pm
by it2051229
riiggghhhhtttttt.

Re: A perfect ORDER BY rating
Posted: Thu Jan 15, 2009 8:16 pm
by alex.barylski
Up 5, Down 0 has a great rate, but only 5 rates so it loses against 10/5.
Depends on how you define 'loses' I suppose. Statistically, the former is perfect at least hitherto, whereas the latter might be more worn and rated lower.
I think you need to separate 'rating' from 'weight' and you should find the answer you seek.
p.s-I would buy a product rated 5/5 5 times over a product rated 1/5 500 times any day.
Cheers,
Alex
Re: A perfect ORDER BY rating
Posted: Thu Jan 15, 2009 10:04 pm
by allspiritseve
You may want to check out the bottom of this page:
http://www.imdb.com/chart/top
IMDB has a weighted system for rating movies.
Also, I know there are plenty of statistical formulas that could give you p values, t values, etc., that would allow you a standard weighting system rather than something homegrown. I can't think of any specifically off the top of my head, it's been a while since I've taken a stats class.
Re: A perfect ORDER BY rating
Posted: Fri Jan 16, 2009 9:17 am
by kaisellgren
allspiritseve wrote:You may want to check out the bottom of this page:
http://www.imdb.com/chart/top
IMDB has a weighted system for rating movies.
Also, I know there are plenty of statistical formulas that could give you p values, t values, etc., that would allow you a standard weighting system rather than something homegrown. I can't think of any specifically off the top of my head, it's been a while since I've taken a stats class.
Thanks for the link, so IMDB uses this algorithm:
The formula for calculating the Top Rated 250 Titles gives a true Bayesian estimate:
weighted rating (WR) = (v ÷ (v+m)) × R + (m ÷ (v+m)) × C
where:
R = average for the movie (mean) = (Rating)
v = number of votes for the movie = (votes)
m = minimum votes required to be listed in the Top 250 (currently 1300)
C = the mean vote across the whole report (currently 6.7)
EDIT: Ok that's hard to port to a thumbs up/down system :p
Re: A perfect ORDER BY rating
Posted: Fri Jan 16, 2009 10:41 am
by allspiritseve
kaisellgren wrote:EDIT: Ok that's hard to port to a thumbs up/down system :p
Probably... your first example was a 5 star system though.
Re: A perfect ORDER BY rating
Posted: Fri Jan 16, 2009 11:04 am
by VladSun
Take a look how ELO (chess players rating) is calculated
http://en.wikipedia.org/wiki/Elo_rating_system
This way a low rated user's vote will increase a high rated user's rating with a small amount. And the opposite - if a high rated user votes for a low rated one, the rating will increase with much more.
It's interesting that in the second case, the rating of the voting user should be decreased.

Re: A perfect ORDER BY rating
Posted: Fri Jan 16, 2009 11:19 am
by kaisellgren
VladSun wrote:Take a look how ELO (chess players rating) is calculated
http://en.wikipedia.org/wiki/Elo_rating_system
This way a low rated user's vote will increase a high rated user's rating with a small amount. And the opposite - if a high rated user votes for a low rated one, the rating will increase with much more.
It's interesting that in the second case, the rating of the voting user should be decreased.

Oh yes ELO! I have a one of 1981

(Hint -- I'm a chess player

)
I'm already working on a second version of my "perfect sorting"

Re: A perfect ORDER BY rating
Posted: Fri Jan 16, 2009 11:32 am
by VladSun
//offtopic
kaisellgren wrote:Oh yes ELO! I have a one of 1981

(Hint -- I'm a chess player

)
Oh! You look younger than you are

At least you are elder than me
Wanna play?

Re: A perfect ORDER BY rating
Posted: Fri Jan 16, 2009 11:45 am
by kaisellgren
VladSun wrote://offtopic
kaisellgren wrote:Oh yes ELO! I have a one of 1981

(Hint -- I'm a chess player

)
Oh! You look younger than you are

At least you are elder than me
Wanna play?

Let's see maybe we could. Do you know good online web sites to play chess free? I've used
http://www.aapeli.com a couple of times, but it's in Finnish, however, we only need to recognize the pawns to play the chess
I just turned out 19.
EDIT: If we play, there's one rule: Infinite time. I don't play Fischers or other. I think an average game I play lasts 2-3 hours. I'm sure I am able to give you an opponent

I started chess at age of 3, but at that time I was only able to move pawns based on rules - not able to make rational moves.
Re: A perfect ORDER BY rating
Posted: Fri Jan 16, 2009 12:06 pm
by VladSun
I have a one of 1981
I've read it as "I have ELO since 1981"

My mistake. You are far younger than me

And I don't wanna play with you anymore
My ELO used to be between 1600 and 1700, but for the last couple of years I successfully made it 1450
And I typically play 5 minutes games with 3 seconds added time per move. I don't like playing long games - it makes me nervous and I make a lot of mistakes. I play at Yahoo! Chess.
Re: A perfect ORDER BY rating
Posted: Fri Jan 16, 2009 1:55 pm
by VirtuosiMedia
Not perfect, but maybe a start to play around with...
Code: Select all
<form method="post">
<label>Votes</label>
<input type="text" name="numVotes" />
<label>Points</label>
<input type="text" name="numPoints" />
<input type="hidden" name="submitted" value="TRUE" />
<input type="submit" value="Submit" />
</form>
<?php
if ($_POST['submitted']){
$numVotes = $_POST['numVotes'];
$numPoints = $_POST['numPoints'];
$rating = ($numPoints / $numVotes);
$rank = ($numVotes + $numPoints) * $rating;
echo $rank;
}
?>