⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calc_roc.m

📁 Graphical User Interface, matlab图形界面程序值得参考欢迎下载
💻 M
字号:
function calc_ROC(FX,h,handles)

% Function to plot the ROC curve and estimate the ROC area
% Written by D.LAI 2006 for D2CMatlab
% 
% FX is a m x 2 matrix with column 1 the values of the classifier decision, fx and column 2 the true label. 

[TotalRows, TotalCols]=size(FX);

handles.ROCArea=0;


% Get max and min values of FX

MAX=max(FX(1:TotalRows,1));
MIN=min(FX(1:TotalRows,1));

f1=0;
f2=0;
x1=0;
x2=0;

fmax=MIN-1;
previous=MAX+1;

% Cycle Through the Threshold
ROCData=[0 0];

for i=1:TotalRows+1

   fmax=MIN-1;
   TP=0;
   FP=0;
   TN=0;
   FN=0;
   for k=1:TotalRows
      if ( (FX(k,1)>fmax) & (FX(k,1)< previous) )
          fmax=FX(k,1);
      end       
   end
   
   CurrThres=fmax-1e-5;
   previous=fmax; 
   
   for j=1:TotalRows 
       if(FX(j,1)>CurrThres)
          if(FX(j,2)==+1)
			TP=TP+1;
		  else
			FP=FP+1;
          end
       else
          if(FX(j,1)<=CurrThres)
             if(FX(j,2)==+1)
				 FN=FN+1;
			 else
				 TN=TN+1;
             end
           end
        end
    end 
   
   f1=f2;
   f2=TP/(TP+FN);
   x1=x2;
   x2=1-TN/(TN+FP);
   
   handles.ROCData=[handles.ROCData ; x2 f2];
   handles.ROCArea= handles.ROCArea + 0.5*(x2-x1)*(f1+f2);
   
end

  guidata(h,handles);



   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -