algorithm used to calculate 5 star ratings

前端 未结 14 1143
挽巷
挽巷 2021-01-29 17:49

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 ex

14条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 18:33

    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
    

提交回复
热议问题