📄 gendatout.m
字号:
function z = gendatout(a,n,dR)% z = gendatout(a,n)%% Generate outlier objects in a hypersphere round dataset a. This% dataset should be a one-class dataset. The hypersphere is calculated% from SVDD.%% z = gendatout(a,n,dR)%% The radius can be enlarge by a certain fraction: r' = dR*r_org.% 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<3) dR = 1;end% what is our target data?a = +target_class(a);% compute SVDD with very big s:s_max = max(max(distm(a)));[nra,dim] = size(a);[svx,alf,b]=m_svm(+a,ones(nra,1),2,2,s_max,1/nra,1e-4);% compute from SVDD the mean and radiusnrsv = size(svx,1);meana = sum(svx.*(alf*ones(1,dim)));R = sqrt(mean(sum((svx-(ones(nrsv,1)*meana)).^2,2)));R = dR*R;% generate new dataz = ones(n,1)*meana + randsph(n,dim)*R;%label it as outliers%z = oc_set(dataset([a;z],[ones(size(a,1),1); 2*ones(n,1)]),1);labz = genlab([size(a,1),n],['target ';'outlier']);z = dataset([a;z],labz);return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -