Reputation: 4057
Imagine something like booking reviews, where we have for each review some scores by criteria and a general rating.
For the sake of simplicity i will use letters, but imagine A like comfort, B localization, and so on. Available rating is (1-4)
A B C D
hotel_review1 | 1 2 3 4
hotel_review2 | 2 2 3 3
A B C D
user_weighing | 2 3 2 3
For the global rating I have this (just a basic weighing avg):
For the avg of each criteria, I am doing an arithmetic avg and after that, multiply the result by the user_weighing:
A - ((1+2)/2)*2/4 = 0.75
B - ((2+2)/2)*3/4 = 1.5
C - ((3+3)/2)*2/4 = 1.5
D - ((4+3)/2)*3/4 = 2.625
-----
6.375 / 4 = 1.60
So, my problem is that i need a general score, in my case 2.55. However if i look for each score independently, there is a big difference between 2.55 and 1.60. There is a better way of doing what I am looking for?
Upvotes: 1
Views: 111
Reputation: 24427
As mentioned by Juhana in the comments, you need to divide by the sum of the weights, which is 10 (2 + 3 + 2 + 3), and not by the number of weights, which is 4:
A: ((1+2)/2)*2/10 = 0.3
B: ((2+2)/2)*3/10 = 0.6
C: ((3+3)/2)*2/10 = 0.6
D: ((4+3)/2)*3/10 = 1.05
-----
2.55
However it is a more simple calculation requiring less operations if you leave the divisions by the number of reviews (2) and the sum of weights (10) until the end:
A: (1+2)*2 = 6.0
B: (2+2)*3 = 12.0
C: (3+3)*2 = 12.0
D: (4+3)*3 = 21.0
-----
51.0 / (2*10) = 2.55
Upvotes: 1