我有一个现有的网络应用程序,允许用户根据难度对项目进行“评分”。(0 到 15)。目前,我只是取每个用户意见的平均值,并直接从 MySQL 中呈现平均值。但是,我(和我的用户)越来越清楚,对数字进行加权会更合适。
奇怪的是,几个小时的谷歌搜索并没有出现太多。我确实找到了两篇文章,它们显示了基于“贝叶斯过滤器”(我部分理解)的站点范围的评级系统。 这是一个例子:
公式为:
WR=(V/(V+M)) * R + (M/(V+M)) * C
在哪里:
* WR=Weighted Rating (The new rating) * R=Average Rating (arithmetic mean) so far * V=Number of ratings given * M=Minimum number of ratings needed * C=Arithmetic mean rating across the whole site
我喜欢这里的想法,即根据每个项目的总票数来增加权重……但是,因为我网站上的难度级别可能因项目而异,取“C”(算术平均评分)网站)无效。
所以,重述我的问题:
使用 MySQL、PHP 或两者兼而有之,我尝试从算术平均值中获取:
(5 + 5 + 4)/3 = 4.67 (rounded)
...加权平均:
rating / weight
5 / 2 (since it was given 2 times)
5 / 2
4 / 1
(sum[(rate * weight)])/(sum of weights)
(5 * 2) + (5 * 2) + (4 * 1) / (2 + 2 + 1)
(24)/(5)
= 4.8