?? gauss_dd.m
字號:
%GAUSS_DD Gaussian data description.% % W = gauss_dd(A,fracrej,r)% % Fit a Gaussian density on dataset A. If requested, the r can be% given to add some regularization to the estimated covariance matrix:% sig_new = (1-r)*sig + r*eye(dim). Default r = 0.1!!!!! (might be% dangerous!)% % See also datasets, mappings, dd_roc% Copyright: D. Tax, R.P.W. Duin, duin@ph.tn.tudelft.nl% Faculty of Applied Physics, Delft University of Technology% P.O. Box 5046, 2600 GA Delft, The Netherlands function [W,out] = gauss_dd(a,fracrej,r)if nargin < 3, r = 0.1; endif nargin < 2 | isempty(fracrej), fracrej = 0.05; endif nargin < 1 | isempty(a) W = mapping(mfilename,{fracrej}); returnendif isa(fracrej,'double') %training if ~isa(a,'dataset') %train on training set error('I need a dataset to train'); end a = target_class(a); % only use the target class [nlab,lablist,m,k,c,prob,featlist] = dataset(a); % train it: [mu,sig] = meancov(a); sig = (1-r)*sig + r*eye(k); % obtain the threshold: p = gausspdf(a,+mu,sig); thr = threshold(p,fracrej); %and save all useful data: W.m = +mu; W.s = sig; W.threshold = thr;% W = {+mu,sig,thr,mean(d)}; W = mapping(mfilename,W,str2mat('target','outlier'),k,c);else %testing [nlab,lablist,m,k,c,p,featlist] = dataset(a); [W,classlist,type,k,c] = mapping(fracrej); % unpack %compute, target class > 0: newout = [gausspdf(a,W.m,W.s) ones(m,1)*W.threshold]; W = dataset(newout,getlab(a),classlist,p,lablist);endreturn
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -