⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nndd.m

📁 data description toolbox 1.6 单类分类器工具包
💻 M
字号:
%NNDD Nearest neighbour data description method.% %       W = NNDD(A,FRACREJ)% % Calculates the Nearest neighbour data description. Training only% consists of the computation of the resemblance of all training% objects to the training data using Leave-one-out.%% WARNING: this method is basically a wrapper around dnndd, which is the% nearest neighbor directly on distance data. In NNDD the squared% Euclidean distance is used.% % See also knndd, datasets, mappings, dd_roc, dnndd% Copyright: D.M.J. Tax, D.M.J.Tax@prtools.org% Faculty EWI, Delft University of Technology% P.O. Box 5031, 2600 GA Delft, The Netherlands  function W = nndd(a,fracrej)if nargin < 2 | isempty(fracrej), fracrej = 0.05; endif nargin < 1 | isempty(a) % empty nndd	W = mapping(mfilename,{fracrej});	W = setname(W,'Nearest neighbour data description');	returnendif ~ismapping(fracrej)           %training	a = +target_class(a);      % make sure we have a OneClass dataset	[m,k] = size(a);	% Compute distance matrix and remove zero distances:	distmat = sqeucldistm(a,a);	large_D = max(distmat(:));	small_D = 1.0e-10;           % almost zero distance	distmat = distmat + large_D*(distmat<small_D); %surpress 0 dist.	% Now go to the dnndd:	w = dnndd(distmat,fracrej);	% and save all useful data:	W.w = w;	W.x = +a;	W.threshold = w.data.threshold;	W = mapping(mfilename,'trained',W,str2mat('target','outlier'),k,2);	W = setname(W,'Nearest neighbour data description');else                               %testing	W = getdata(fracrej);  % unpack	m = size(a,1);	%compute:	distmat = +sqeucldistm(+a,W.x);	out = +(distmat*W.w);   % and return it nicely	W = setdat(a,out,fracrej);	W = setfeatdom(W,{[-inf 0] [-inf 0]});endreturn

⌨️ 快捷键说明

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