开发者

Weighted voting algorithm

开发者 https://www.devze.com 2023-01-24 06:08 出处:网络
I\'m looking开发者_如何学编程 for information on which voting algorithm will be best for me.I have a basic \'Up/Down\' voting system where a user can only vote the product up or down.I would like to m

I'm looking开发者_如何学编程 for information on which voting algorithm will be best for me. I have a basic 'Up/Down' voting system where a user can only vote the product up or down. I would like to make it weighted so that a product that is a year old will not be held to the same standards as one that is brand new.

I'm thinking do an algorithm that takes the amount of votes for each product in the last 30 days. However this creates a draw back. I don't want votes older than 30 days to become meaningless, but maybe not weighted as much as newer ones. Then possibly votes after 90 days are even weighted less than ones older than 30 days.

Is anyone aware of an algorithm that does this already and even more so is able to be calculated easily in PHP?


Google App Engine has a nice example that deals with votes that "decay" over time.

It's in Python, but it should fit your needs.


I think that given the simplicity of your requirement, the best course of action is write this yourself.

Without knowing more, I think your challenge will be in deciding whether you save this data into your database in a pre-weighted format (e.g. "when vote is cast, give it $this_year + 1 points"), whether you calculate the weighting in your db query (e.g. order by a score that accounts for both upvotes and the date when a vote was cast), or whether you return all the needed data and deduce the weighting in PHP. The choice depends on what your app needs to do exactly and how much data there will be.

0

精彩评论

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