我如何使用 libsvm 作为 matlab 中的二元分类器来计算灵敏度(真阳性率)和特异性(真阴性率)?
How can i calculate sensitivity(True positive rate) and specificity(True negative rate) using libsvm as a binary classifier in matlab?
我正在研究人脸验证 problem.I 我正在使用 LibSVM 作为分类器。我想计算真阳性率和真阴性率。
通过这两个性能指标,我想计算Equal error rate,也想画ROC曲线。
我在 matlab.But 中读到了 perfcurve 命令
如果您使用的是 libsvm,svmpredict
函数中有三个可能的 return 值。
[predicted_label, accuracy, decision_values] = svmpredict(testing_label_vector, testing_instance_matrix, model [,'libsvm_options']);
如果你没有指定你想要所有的 return 值,通过将输出分配给使用几个变量,你将只会得到第一个变量,predicted_label
.
如果要生成 ROC 曲线,则需要每个实例的分类器分数才能计算阈值。分数是decision_values
。
然后您可以使用机器学习工具包中的任一 roc
or plotroc
from the Neural Network Toolkit or perfcurve
来生成您的 ROC 曲线。
对于每个阈值的真阳性率和假阳性率以元胞数组的形式,使用
[tpr,fpr,thresholds] = roc(ground_truth, decision_values);
对于 ROC 曲线图,使用
plotroc(ground_truth, decision_values);
或
[X,Y] = perfcurve(ground_truth, decision_values, positive_class_name);
plot(X,Y);
有关另一个 perfcurve
示例,请参阅 ROC curve for a binary classifier in MATLAB。
我正在研究人脸验证 problem.I 我正在使用 LibSVM 作为分类器。我想计算真阳性率和真阴性率。
通过这两个性能指标,我想计算Equal error rate,也想画ROC曲线。
我在 matlab.But 中读到了 perfcurve 命令
如果您使用的是 libsvm,svmpredict
函数中有三个可能的 return 值。
[predicted_label, accuracy, decision_values] = svmpredict(testing_label_vector, testing_instance_matrix, model [,'libsvm_options']);
如果你没有指定你想要所有的 return 值,通过将输出分配给使用几个变量,你将只会得到第一个变量,predicted_label
.
如果要生成 ROC 曲线,则需要每个实例的分类器分数才能计算阈值。分数是decision_values
。
然后您可以使用机器学习工具包中的任一 roc
or plotroc
from the Neural Network Toolkit or perfcurve
来生成您的 ROC 曲线。
对于每个阈值的真阳性率和假阳性率以元胞数组的形式,使用
[tpr,fpr,thresholds] = roc(ground_truth, decision_values);
对于 ROC 曲线图,使用
plotroc(ground_truth, decision_values);
或
[X,Y] = perfcurve(ground_truth, decision_values, positive_class_name);
plot(X,Y);
有关另一个 perfcurve
示例,请参阅 ROC curve for a binary classifier in MATLAB。