oc_set.m

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

M
47
字号
function a = oc_set(a,clnr)% OC_SET  makes an one-class dataset%% A = oc_set(A,clnr)%% Change a normal dataset A into an one-class dataset: the class% indicated by the classnr (clnr) is made target class and all other% data becomes outliers class. The labels are changed to 'target' and% 'outlier'.%% It is also possible to use a class label:%% A = oc_set(A,label)%% but then the type of the label should be a char (else you cannot% distinguish it from a class number, can you?:-))% 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 Netherlandsif (nargin<2)  clnr = 1;end% match the labellist type with the clnr[nlab,lablist,m,k,c] = dataset(a);if isa(clnr,'char')  if isa(lablist,'double')    [nlab,clnr] = renumlab(getlab(a),str2num(clnr));  else % lablist is character    [nlab,clnr] = renumlab(getlab(a),clnr);  endend% make the new labels:lablist =  str2mat('target', 'outlier');laba = ones(m,size(lablist,2));I = find(nlab==clnr);laba(I,:) = ones(length(I),1)*lablist(1,:);I = find(nlab~=clnr);laba(I,:) = ones(length(I),1)*lablist(2,:);a = dataset(+a,char(laba));return

⌨️ 快捷键说明

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