基于投票从 1 到 5 的人气排名算法
Popularity ranking algorithm based on votes from 1 to 5
我正在开发一个新网站,其中有一些 "entities" 可以投票。
每票可以是 1 到 5 之间的数字,其中 1 是最差的一票,5 是最好的一票。
现在,在同一个网站上,我有一个 "Popular entities chart",我根据他们的投票列出了最受欢迎的 "entities"。
现在,我不能做简单的算术平均,因为 "entity" 一票 5 票的排名可能与 "entity" 100 票 5 的排名相同。
我考虑过为每个 "entity" 不仅存储算术平均值,还存储票数,然后进行 SQL 查询,我按票数和算术平均值排序,但似乎之后这样,一个实体有很多票 1 可能会受欢迎(当它不受欢迎时)。
我可以使用什么算法?
对于基本解决方案,请尝试 order by [average vote] desc, [vote count] desc
从具有相同平均值的两个实体中采用这种方法,获得 100 票的将超过获得 1 票的实体,但平均为 4.5 的实体将永远不会超过一个平均为 5.
编辑 1
如果您想要 100 票平均 4.5 胜 10 票平均 5,为什么不计算忽略 1、2 和 3 的选票,或者 [计票 4 和5] - [计票 1 和 2]?这样 正面 票数将拉高实体的排名。
编辑 2
您可能希望格外重视最近的投票。某个实体可能发生了某些变化,从而改变了用户对它的看法。可以建立上个月的另一个平均票数,并根据它调整最终排名。
编辑 3
如何计算 [popularityScore] 列并按它排序?
-- sum instead of average
-- square root of sum will reduce importance of vote count a bit
select
entity,
sqrt(sum(vote - 3)) as popularityScore
from Votes
group by entity
order by rank desc
-- 50 votes of 5 -> popularityScore = 12.25
-- 100 votes of 4 -> popularityScore = 10
-- 200 votes of 4 -> popularityScore = 14.14
-- 2000 votes of 4 -> popularityScore = 44.72
-- 2000 votes of 5 -> popularityScore = 63.25
-- 100000000 votes of 3 -> popularityScore = 0
可以计算上个月的相同分数并将其添加到此值。
我正在开发一个新网站,其中有一些 "entities" 可以投票。
每票可以是 1 到 5 之间的数字,其中 1 是最差的一票,5 是最好的一票。
现在,在同一个网站上,我有一个 "Popular entities chart",我根据他们的投票列出了最受欢迎的 "entities"。
现在,我不能做简单的算术平均,因为 "entity" 一票 5 票的排名可能与 "entity" 100 票 5 的排名相同。
我考虑过为每个 "entity" 不仅存储算术平均值,还存储票数,然后进行 SQL 查询,我按票数和算术平均值排序,但似乎之后这样,一个实体有很多票 1 可能会受欢迎(当它不受欢迎时)。
我可以使用什么算法?
对于基本解决方案,请尝试 order by [average vote] desc, [vote count] desc
从具有相同平均值的两个实体中采用这种方法,获得 100 票的将超过获得 1 票的实体,但平均为 4.5 的实体将永远不会超过一个平均为 5.
编辑 1
如果您想要 100 票平均 4.5 胜 10 票平均 5,为什么不计算忽略 1、2 和 3 的选票,或者 [计票 4 和5] - [计票 1 和 2]?这样 正面 票数将拉高实体的排名。
编辑 2
您可能希望格外重视最近的投票。某个实体可能发生了某些变化,从而改变了用户对它的看法。可以建立上个月的另一个平均票数,并根据它调整最终排名。
编辑 3
如何计算 [popularityScore] 列并按它排序?
-- sum instead of average
-- square root of sum will reduce importance of vote count a bit
select
entity,
sqrt(sum(vote - 3)) as popularityScore
from Votes
group by entity
order by rank desc
-- 50 votes of 5 -> popularityScore = 12.25
-- 100 votes of 4 -> popularityScore = 10
-- 200 votes of 4 -> popularityScore = 14.14
-- 2000 votes of 4 -> popularityScore = 44.72
-- 2000 votes of 5 -> popularityScore = 63.25
-- 100000000 votes of 3 -> popularityScore = 0
可以计算上个月的相同分数并将其添加到此值。