[英]Get recall (sensitivity) and precision (PPV) values of a multi-class problem in PyML
I am using PyML for SVM classification.我正在使用PyML进行 SVM 分类。 However, I noticed that when I evaluate a multi-class classifier using LOO, the results object does not report the sensitivity and PPV values.但是,我注意到当我使用 LOO 评估多类分类器时,结果对象不会报告灵敏度和 PPV 值。 Instead they are 0.0:相反,它们是 0.0:
from PyML import *
from PyML.classifiers import multi
mc = multi.OneAgainstRest(SVM())
data = VectorDataSet('iris.data', labelsColumn=-1)
result = mc.loo(data)
result.getSuccessRate()
>>> 0.95333333333333337
result.getPPV()
>>> 0.0
result.getSensitivity()
>>> 0.0
I have looked at the code but couldn't figure out what is going wrong here.我查看了代码,但无法弄清楚这里出了什么问题。 Has somebody a workaround for this?有人有解决方法吗?
You cannot get the usual Precision/Recall measurements on a multi-class problem.对于多类问题,您无法获得通常的 Precision/Recall 测量值。 You have to get Precision/Recall for each class, and you can compute a weighted average.您必须获得每个类别的 Precision/Recall,并且您可以计算加权平均值。
I don't know about the specifics of PyML, but you can just go through the predictions and calculate them for each class.我不知道 PyML 的细节,但你可以通过预测并为每个类计算它们。
For multiclass sensitivity calculation, you can use scikit-learn metrics API .对于多类敏感性计算,您可以使用scikit-learn 指标 API 。
Notice
average=None
for sensitivity of each class independently.注意每个类别独立的敏感性average=None
。
sklearn.metrics.recall_score(Y_true,Y_prediction,average=None)
For instance, if Y
has 4 classes, the result will be an array with the sensitivity of each one.例如,如果Y
有 4 个类,结果将是一个具有每个类的敏感度的数组。
array([0.96629213, 0.86263736, 0.81920904, 0.7704918])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.