?? errors.m
字號:
function [area,roc] = errors(netans,answer,outfile)% WBL 23 August 2002 Caculate true positive and false positive rates for all tresholds% Returning the ROC and the area under its convex hull.% $Revision: 1.6 $ $Date: 2002/10/31 11:24:12 $%Inputs: netans two neurons% answer actual class (0 or 1)% outfile FID of a stream for output% WBL 20 Sep calculate and save errors at Threshold=0.5% WBL 16 Sep based on errors.m Caclculate complete ROC not just 11 sample points[Qx,ntestsx] = size(answer); %Q is junk%use difference between both neurons as probability of 1%then rescale for comparison with threshold Tx.netconf = (0.5 + 0.5*( netans(2,:) - netans(1,:) ) );%[netans; netconf][B,index] = sort(netconf);roc = zeros(ntestsx,2);for i=1:ntestsx-1 tn = sum(~answer(index(1:i))); fn = i-tn; tp = sum(answer(index(i+1:ntestsx))); fp = (ntestsx-i)-tp; TP = tp/sum(answer); FP = fp/sum(~answer); roc(i,1) = TP; roc(i,2) = FP;endTX = 0.5;AAx = netconf > TX;%TX= median(netconf);%AAx = netconf > median(netconf);e = sum(abs(AAx-answer))/ntestsx;tn = sum(~answer & ~AAx);fn = sum( answer & ~AAx);fp = sum(~answer & AAx);tp = sum( answer & AAx);TP = tp/sum(answer);FP = fp/sum(~answer);fprintf('%f %f %f %3d %3d %3d %3d %f ',... TX,TP,FP,tn,fn,fp,tp,e);fprintf(outfile,'%2f %f %f %3d %3d %3d %3d %f ',... TX,TP,FP,tn,fn,fp,tp,e); area=auroc(roc,TP,FP);fprintf('Area under ROC %f\n',area);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -