def calc_disagreement(evaluations):
"""Return the disagreement level for evaluations, or None if no evaluations.
Calculated as the max disagreement of (1) N/A and non-N/A responses and (2) non-N/A evaluations
:param evaluations: an iterable of Eval
"""
if evaluations:
na_it, rated_it = partition(lambda x: x is not Eval.not_applicable, evaluations)
na_votes = list(na_it)
rated_votes = list(rated_it)
# Here we use the sample standard deviation because we consider the evaluations are a sample of all the
# evaluations that could be given.
# Not clear the best way to make the N/A disagreement comparable to the evaluation disagreement calculation
na_disagreement = (
statistics.stdev(([0] * len(na_votes)) + ([1] * len(rated_votes)))
if len(na_votes) + len(rated_votes) > 1
else 0.0)
rated_disagreement = (
statistics.stdev([v.value for v in rated_votes])
if len(rated_votes) > 1
else 0.0)
return max(na_disagreement, rated_disagreement)
else:
return None
评论列表
文章目录