ROC曲线和libsvm [英] ROC curve and libsvm

查看:106
本文介绍了ROC曲线和libsvm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出用plotroc.m绘制的ROC曲线(请参见此处):

Given a ROC curve drawn with plotroc.m (see here):

  1. 理论问题:如何选择要使用的最佳阈值?
  2. 编程问题:如何使libsvm分类器以选定的(最佳)阈值工作?
  1. Theoretical question: How to select the best threshold to be used?
  2. Programming qeuestion: How to induce the libsvm classifier to work with the selected (best) threshold?

推荐答案

ROC曲线是通过在y轴上绘制真正分数与在x轴上绘制假正分数所生成的图.因此,ROC曲线上任意点(x,y)的坐标表示特定阈值处的FPR和TPR值. 如图所示,我们在ROC曲线上找到了点(x,y),该点对应于该点距图的左上角的最小距离(即由(0,1)给出).对应于该点的阈值是所需阈值.抱歉,我不允许放置任何图像,所以无法用数字解释.但是,有关此操作的更多详细信息,请单击与ROC相关的帮助

ROC curve is plot generated by plotting fraction of true positive on y-axis versus fraction of false positive on x-axis. So, co-ordinates of any point (x,y) on ROC curve indicates FPR and TPR value at particular threshold. As shown in figure, we find the point (x,y) on ROC curve which corresponds to the minimum distance of that point from top-left corner (i.e given by(0,1)) of plot. The threshold value corresponding to that point is the required threshold. Sorry, I am not permitted to put any image, so couldn't explain with figure. But, for more details about this click ROC related help

第二,在libsvm中,svmpredict函数返回属于特定类的数据样本的概率.因此,如果该概率(对于阳性类别)大于阈值(从ROC图获得),则可以将样本分类为阳性类别.以下几行可能对您有用:

Secondly, In libsvm, svmpredict function returns you probability of data sample belonging to a particular class. So, if that probability(for positive class) is greater than threshold (obtained from ROC plot) then we can classify the sample to positive class. These few lines might be usefull to you:

    [pred_labels,~,p] = svmpredict(target_labels,feature_test,svmStruct,'-b 1');

%其中,svmStruct是svmtrain函数返回的结构.

    op = p(:,svmStruct.Label==1);  % This gives probability for positive
% class (i.e whose label is 1 )

现在,如果此变量"op"大于阈值,则可以将相应的测试样品分类为阳性.可以这样做

Now if this variable 'op' is greater than threshold then we can classify the corresponding test sample to positive class. This can be done as

op_labels = op> th; %,其中"th"是从ROC获得的阈值

op_labels = op>th; % where 'th' is threshold obtained from ROC

这篇关于ROC曲线和libsvm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆