target_class.m

来自「数据挖掘的工具箱,最新版的,希望对做这方面研究的人有用」· M 代码 · 共 58 行

M
58
字号
function [a,b] = target_class(a,clnr)% TARGET_CLASS  extracts the target class from an one-class dataset%%    A = target_class(A,CLNR)%% Extract the target class from an one-class dataset. When the label% CLNR is given, the class indicated by this label is taken.%%    [A,B] = target_class(A,CLNR)%% When a second output argument is requested, %% Default: CLNR='target';%% See also: oc_set, gendatoc, find_target, relabel% 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 Netherlandsif (nargin<2)  clnr = 'target';end% Be sure we are working with an OC set:[a,I] = oc_set(a,clnr);% Extract just the target objects:It = find(I==1);if isempty(It)	error('Cannot find target class objects!');end% On request, also return the outlier objects:% (do this before the construction of the target-class dataset, because% in that construction the outlier data is removed)if nargout>1	Io = find(I==2);	b = a(Io,:);	%DXD  Now the question becomes, should we reduce the lablist to just	% 'outlier'??	b = setnlab(b,ones(length(Io),1));	b = setlablist(b); % remove empty classes.	b = setlablist(b,'outlier');end% and what it was all about:a = a(It,:);%DXD  Now the question becomes, should we reduce the lablist to just% 'target'??a = setlablist(a); % remove empty classes from the lablista = setnlab(a,ones(length(It),1));a = setlablist(a,'target');return

⌨️ 快捷键说明

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