dd_error.m

来自「模式识别工具箱,希望对大家有用!」· M 代码 · 共 37 行

M
37
字号
function e = dd_error(w,x)
%DD_ERROR compute false positive and false negative for oc_classifier
%
%   e = dd_error(w,x)
%
% Compute the fraction of target objects rejected and the fraction of outliers
% accepted:
%    e(1) = target rejected
%    e(2) = outlier accepted

% Copyright: D. 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

[nin,llin] = renumlab(getlab(x));
if (size(llin,1)~=2)
  error('DD_ERROR: both target and outlier examples are required');
end
lout = classd(w*x);
[nout,llout] = renumlab(lout);
e=[0 0];
difl = nin - nout;    % where do the two labels disagree?
% what is the target class?
nr = strmatch('target ',llin); % should be 1 or 2 ...
if isempty(nr)   % no match could be found, no space in the end?
  nr = strmatch('target',llin);
end
if isempty(nr)
  error('DD_ERROR: cannot find the target class');
end

% find the number of disagreements for target and outlier class:
e(nr) = length(find(difl==-1))/length(find(nin==1));
e(3-nr) = length(find(difl==1))/length(find(nin==2));

return

⌨️ 快捷键说明

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