Search code examples
algorithmrankingvoting

Algorithm for ranking with a star rating (1-5) like Amazon?


I'm a CS student doing a report on alternative voting systems. One of the best systems I believe is a ranked vote. For example.. In a presidential election, each president would be ranked 1-5. (IMO the problem with the US system is that only votes for the winner actually count)

Just wondering if anyone knows the best way to add up the ratings? I have searched around and I know Amazon uses weighted averages. I would think it might make sense to just add up each "star" and the person with the most wins. Maybe someone more mathematically inclined can suggest something better?


Solution

  • One fun thing you can do to a rating system is pass the votes through a low pass filter. This helps eliminate extremes where some dude out of 100 just wants to troll blam something. This also helps mitigate those people that after they initially post something they 5 star their product with there self made accounts.

    An average does almost the same thing, but a low pass filter you can bias the voting system to be harder or easier to raise the ranking or keep a ranking which can vary from subject to subject.

    A low pass filter can look as simple as:

    ranks = [2,3,1,2,4,2,1,2,3,4,3,4,2]
    y = [ranks[0], ranks[1], ranks[2]]
    
    for(i=2; i<ranks.length; ++i)
        currentRank = .2*ranks[i] + .3*y[2] + .2*y[1] + .3*y[0]
        y.push(currentRank)
        y.shift()
    

    There are other properties to using a filter like this, but that would just require to research Digital Low Pass Filters to find those cool properties out :)