📄 roc.html
字号:
<html><head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"> <title>roc.m</title><link rel="stylesheet" type="text/css" href="../../m-syntax.css"></head><body><code><span class=defun_kw>function</span> <span class=defun_out>[FP,FN]</span>=<span class=defun_name>roc</span>(<span class=defun_in>dfce,y</span>)<br><span class=h1>% ROC Computes Receive Operator Characteristic.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Synopsis:</span></span><br><span class=help>% [FP,FN]=roc(dfce,y)</span><br><span class=help>% </span><br><span class=help>% <span class=help_field>Description:</span></span><br><span class=help>% It computes false positive rate FP and false negative rate FN</span><br><span class=help>% with rescpect to the shift of the bias of given decision function.</span><br><span class=help>% The values of the decision function are given in dfce and y </span><br><span class=help>% contains true labels (number 1 and/or 2). The vectors dfce and y </span><br><span class=help>% must be of the same length. </span><br><span class=help>% The bias is shifted from min(dfce) to max(dfce). </span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Input:</span></span><br><span class=help>% dfce [1 x num_data] Values of decision function returned by </span><br><span class=help>% a classifier.</span><br><span class=help>% y [1 x num_data] True labels.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Output:</span></span><br><span class=help>% FP [1 x num_data] False positive rate.</span><br><span class=help>% FN [1 x num_data] False negative rate.</span><br><span class=help>%</span><br><span class=help>% <span class=help_field>Example:</span></span><br><span class=help>% data = load('riply_trn');</span><br><span class=help>% model = fld(data);</span><br><span class=help>% [y_pred,dfce] = linclass(data.X,model);</span><br><span class=help>% [FP,FN] = roc(dfce,data.y);</span><br><span class=help>% figure; hold on; plot(FP,FN);</span><br><span class=help>% xlabel('false positives'); </span><br><span class=help>% ylabel('false negatives');</span><br><span class=help>%</span><br><span class=help>% See also </span><br><span class=help>% CERROR</span><br><span class=help>%</span><br><hr><span class=help1>% <span class=help1_field>(c)</span> Statistical Pattern Recognition Toolbox, (C) 1999-2003,</span><br><span class=help1>% Written by Vojtech Franc and Vaclav Hlavac,</span><br><span class=help1>% <a href="http://www.cvut.cz">Czech Technical University Prague</a>,</span><br><span class=help1>% <a href="http://www.feld.cvut.cz">Faculty of Electrical engineering</a>,</span><br><span class=help1>% <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a></span><br><br><span class=help1>% <span class=help1_field>Modifications:</span></span><br><span class=help1>% 17-may-2004, VF</span><br><span class=help1>% 6-June-2003, VF</span><br><span class=help1>% 24-Feb-2003, VF</span><br><br><br><hr>num_data=length(dfce);<br>n1=length(find(y==1));<br>n2=length(find(y==2));<br><br>[dfce,inx]=sort(dfce);<br>y = y(inx);<br><br>FP=zeros(1,num_data);<br>FN=zeros(1,num_data);<br><br>wrong1=0;<br>wrong2=n2;<br><br><span class=keyword>for</span> i=1:num_data,<br> <span class=keyword>if</span> y(i) == 1,<br> wrong1=wrong1+1;<br> <span class=keyword>else</span><br> wrong2=wrong2-1;<br> <span class=keyword>end</span><br> <br> FP(i)=wrong2/n2;<br> FN(i)=wrong1/n1;<br><span class=keyword>end</span><br><br><span class=jump>return</span>;<br></code>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -