本文介绍了用于计算5星级的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要像亚马逊网站上那样计算5星级。我已经进行了足够的搜索以找到最佳的算法,但是我找不到正确的答案。例如,如果这些是评分

I need to calculate 5-star ratings like the one on Amazon website. I have done enough search to find what is the best algorithm, but I am not able to get a proper answer. For example, if these are the ratings

5 star - 252
4 star - 124
3 star - 40
2 star - 29
1 star - 33

总共478条点评

亚马逊将其计算为 4.1星(满分5星)。谁能告诉我这个数字是怎么得出的?我不能仅仅通过求平均值来得到这个值。

Amazon has calculated this to be "4.1 out of 5 stars". Can anyone tell me how this figure is arrived at? I am not able to get this just by doing average.

推荐答案

这是加权平均值,其中您用数字对每个评分进行加权的投票数:

That's a weighted average, where you weigh each rating with the number of votes it got:

(5*252 + 4*124 + 3*40 + 2*29 + 1*33) / (252+124+40+29+33) = 4.11 and change

这篇关于用于计算5星级的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 15:34