Exemplo n.º 1
0
 def result(item, threshold, mean):
     """Calculate a score given a threshold and population mean."""
     if not threshold:
         threshold = 1  # Prevent division by zero
     value = item['rating']
     weight = item['ratingcount']
     res_index = item['res_index']
     score_rated = weights.bayesian(weight, value, threshold, mean)
     weight_score = .5
     weight_res = .5
     score_weighted = weight_score * score_rated + weight_res * res_index
     item['score_rated'] = score_rated
     item['score_weighted'] = score_weighted
     return score_weighted, value, weight, item
Exemplo n.º 2
0
 def result(item, threshold, mean):
     """Calculate a score given a threshold and population mean."""
     if not threshold:
         threshold = 1  # Prevent division by zero
     value = item['rating']
     weight = item['ratingcount']
     res_index = item['res_index']
     score_rated = weights.bayesian(weight, value, threshold, mean)
     weight_score = .5
     weight_res = .5
     score_weighted = weight_score * score_rated + weight_res * res_index
     item['score_rated'] = score_rated
     item['score_weighted'] = score_weighted
     return score_weighted, value, weight, item