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

📄 kmeans_dd.m

📁 SVDD的工具箱
💻 M
字号:
%KMEANS_DD k-means data description.% %       W = KMEANS_DD(A,FRACREJ,K)% % Train a k-means method with K prototypes on dataset A. Parameter% fracrej gives the fraction of the target set which will be rejected.% % Optionally, one may give the error tolerance as last argument as% stopping criterion.% % See also knndd, kcenter_dd, som_dd% 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,out] = kmeans_dd(a,fracrej,K,errtol)if nargin < 4,  errtol = 1e-5; endif nargin < 3 | isempty(K), K = 5; endif nargin < 2 | isempty(fracrej), fracrej = 0.05; endif nargin < 1 | isempty(a) % empty dd	W = mapping(mfilename,{fracrej,K,errtol});	W = setname(W,'K-Means data description');	returnendif ~ismapping(fracrej)           %training	a = +target_class(a);     % make sure a is an OC dataset	k = size(a,2);	% train it:	[labs,w] = mykmeans(a,K,errtol);	% obtain the threshold:	d = sqrt(min(sqeucldistm(a,w),[],2));	if (size(d,2)~=1)		d = d';	end	thr = dd_threshold(d,1-fracrej);	%and save all useful data:	W.w = w;	W.threshold = thr;	W.scale = mean(d);	W = mapping(mfilename,'trained',W,str2mat('target','outlier'),k,2);	W = setname(W,'K-Means data description');else                               %testing	W = getdata(fracrej);  % unpack	m = size(a,1);	%compute:	out = [sqrt(min(sqeucldistm(+a,W.w),[],2)) repmat(W.threshold,m,1)];	% Store the distance as output:	W = setdat(a,-out,fracrej);	W = setfeatdom(W,{[-inf 0] [-inf 0]});endreturn

⌨️ 快捷键说明

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