我是阵列编程的新手,发现很难解释sklearn.metrics label_ranking_average_precision_score函数。需要您的帮助以了解其计算方式,并感谢您学习Numpy数组编程的任何技巧。
通常,我知道精度是
((正数)/(正数+误数))
我问这个问题的原因是,我偶然发现了Kaggle音频标记竞赛,并发现这篇帖子说,当响应中有多个正确的标签时,他们正在使用LWRAP函数计算分数。我开始阅读以了解该分数是如何计算的,并发现难以解释。我的两个困难是
1)从文档解释Math函数,我不确定分数计算中如何使用排名
2)从代码解释Numpy数组操作
我正在读取的函数来自Google Collab文档,然后尝试阅读文档在sklearn,但无法正确理解。
一个样本计算的代码是
# Core calculation of label precisions for one test sample.
def _one_sample_positive_class_precisions(scores, truth):
"""Calculate precisions for each true class for a single sample.
Args:
scores: np.array of (num_classes,) giving the individual classifier scores.
truth: np.array of (num_classes,) bools indicating which classes are true.
Returns:
pos_class_indices: np.array of indices of the true classes for this sample.
pos_class_precisions: np.array of precisions corresponding to each of those
classes.
""" …
Run Code Online (Sandbox Code Playgroud) python numpy scikit-learn average-precision multilabel-classification