def score_mod(gold, prediction, method):
"""
Computes correlation coefficient for two lists of values.
:param gold: list of gold values
:param prediction: list of predicted values
:param method: string, can be either of "pearson", "spearman" or "auc" (area under curve)
:return: correlation coefficient and p-value
"""
if len(gold) != len(prediction):
raise ValueError("The two arrays must have the same length!")
gold = np.array(gold, dtype=np.double)
prediction = np.array(prediction, dtype=np.double)
if method == "pearson":
return pearson(gold, prediction)
elif method == "spearman":
return spearman(gold, prediction)
elif method == "auc":
return auc(gold, prediction)
else:
raise NotImplementedError("Unknown scoring measure:%s" % method)
评论列表
文章目录