开发者

Weighted Voting Algorithm/Calculation

开发者 https://www.devze.com 2023-02-13 17:54 出处:网络
I am creating a \'duel\' app and I am at a dead-end to calculating the results. Each user either has an upvote or downvote. There is no 1-5 or five-star rating.

I am creating a 'duel' app and I am at a dead-end to calculating the results.

Each user either has an upvote or downvote. There is no 1-5 or five-star rating.

For example: If I were displayed 5 times and won 3, I would have 3 'upvotes' and 2 'downvotes'.

If I did straight percentages, any who was displayed 1 time and selected 1 time (100%) would always be the top where as if someone was 9/10 (90%) they would be below the 1/1 but in theory would bel开发者_JAVA技巧ong on top.

Anyone have any ideas of how to accomplish this?


I, too, have been looking for a suitable algorithm for a voting website.

Whilst what @joshhendo suggested would appear to be a sound method of ranking votes, it doesn't take into account the percentage of positive votes.

For example:

  • Item 1 has 70 'up' votes and 30 'down' votes.
  • Item 2 has 400 'up' votes and 300 'down' votes.

For Item 1: 70-30 = 40
For Item 2: 400-300 = 100

Item 2 will appear above Item 1 because it has more positive votes. But Item 2 only has 25% positive votes, whereas Item 1 has ~57% positive votes. Item 1 should obviously appear above Item 2, because even though it doesn't have as many overall votes, it has a better 'up' to 'down' ratio of votes.

But then again, one wants to avoid the initial problem of items with 1 vote (positive) appearing above everything else.

I recommend you read this: http://www.evanmiller.org/how-not-to-sort-by-average-rating.html

It suggests a more mathematically sound solution to this problem. It's actually a very interesting read, and I will be implementing something similar into my own website.

[edit]
This is also a very good read: http://blog.linkibol.com/2010/05/07/how-to-build-a-popularity-algorithm-you-can-be-proud-of/
[/edit]


Rather than the positive vote percent, track a bayesian average of that, e.g.:

(positive votes + weighted avg positive votes) / (total votes + arbitrary sample)

http://en.wikipedia.org/wiki/Bayesian_average


You could just tally up the votes, with an up vote counting as +1 and a down vote counting as -1.

For example, lets say someone was 9/10 (for example, had 9 up votes and 1 down vote), then their score would be 9 + -1 = 8. This is higher than 1/1, who has 1 up vote and 0 down votes, therefore their score would be 1 + -0 = 1. So, the person who would have got 90% in your percentage system now has a score of 8, which is higher than the person who would have got 100% with a score of 1.

That's the best and simplest solution I can think of. There may be more complex solutions that would work, but for what you want, I think that should work.


You can have a weighted score.

track each users's points, and a ranking-score

let q be your opponents score (which is in range of 0 to 1 inclusive on both ends.)

When you do battle, you gain 1-q points when you win and you lose q points when you lose. This means if you lose against someone who always wins, that's not going to hurt you much. If you lose to someone who almost always loses, you're going to lose lots of points for it.

Each (day, hour, whatever) recalculate everyone's q, where the #1 person gets a q of 1 (or 1.5, or 2, whatever, but 1 works the best) and the lowest person gets a q of 0.

0

精彩评论

暂无评论...
验证码 换一张
取 消