📄 dd_roc.m
字号:
function e = dd_roc(a,w)%DD_ROC Receiver Operating Characteristic curve %% E = DD_ROC(A,W)% E = DD_ROC(A*W)% E = A*W*DD_ROC%% Find for a (data description) method W the Receiver Operating% Characteristic curve over dataset A. The results are returned in E.% The first column gives the fraction of target objects rejected, the% second column the fraction of outlier objects accepted.%% NOTE: people typically use this ROC definition: false positive FP% (outlier accepted) on the x-axis, and true positive TP (target% accepted) on the y-axis. You can retrieve that by using:% newe = [e(:,2) 1-e(:,1)]% I choose to define E consistent, i.e. both numbers indicate% 'errors'. In the routines plotroc and dd_auc the variable E is% automatically recomputed to get the 'standard' plots and AUC values.%% See also: plotroc, dd_auc, dd_error, simpleroc.%%@article{Metz1978,% author = {Metz, C.E.},% title = {Basic principles of {ROC} analysis},% journal = {Seminars in Nuclear Medicine},% year = {1978},% volume = {VIII},% number = {4},% month = {October}%}% Copyright: D.M.J. Tax, R.P.W. Duin, davidt@ph.tn.tudelft.nl% Faculty of Applied Physics, Delft University of Technology% P.O. Box 5046, 2600 GA Delft, The Netherlands% Use the same setup as testc% When no input arguments are given, return an empty mappingif nargin==0 e = mapping(mfilename,'fixed');elseif nargin == 1 % Now we should have a mapped dataset, so the real work is done! % for evaluation, we need both target and outlier objects: dataset(a); [It,Io] = find_target(a); if isempty(It) error('Dataset A does not contain target objects'); end if isempty(Io) error('Dataset A does not contain outlier objects'); end % get the labels of A: truelab = zeros(size(a,1),1); truelab(It) = 1; % check if we have sane results: if ~all(isfinite(+a)) error('Some strange classifier outputs: can you check your classifier?'); end % first find out where the output for the target objects are stored: tcolumn = strmatch('target ',getfeatlab(a)); if tcolumn~=1 % then we are probably using 'normal' prtools classifiers, and in % that case, the outputs should be normalized if abs(sum(sum(+a)) - size(a,1)) > 1e-9 error('Are the classifier outputs normalized?'); end end % and now extract the required column 'resemblance to target set': a = +a(:,tcolumn); % now the real computation is done: e = simpleroc(a,truelab);else % Separate mapping and dataset are given, so we have to map the data % first: ismapping(w); istrained(w); e = feval(mfilename,a*w);endreturn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -