• B5_569111
    了解作者
  • 235.3KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-16 05:54
    上传日期
很好用的 最小二乘法的支持向量机工具箱~~lssvm 值得一用~~
LS_SVM工具箱.rar
  • LS_SVM工具箱
  • R2009b_R2011a
  • predlssvm.m
    5.2KB
  • lin_kernel.m
    529B
  • plotlssvm.m
    9.7KB
  • rcrossvalidatelssvm.m
    4.1KB
  • demofun.m
    3.9KB
  • linesearch.m
    3.7KB
  • preimage_rbf.m
    4.3KB
  • codedist_hamming.m
    753B
  • bay_modoutClass.m
    9.1KB
  • bay_lssvm.m
    10.1KB
  • bay_optimize.m
    5.7KB
  • medae.m
    302B
  • kernel_matrix2.m
    795B
  • bay_initlssvm.m
    2KB
  • kentropy.m
    2.1KB
  • MLP_kernel.m
    603B
  • codedist_loss.m
    2KB
  • AFEm.m
    3.4KB
  • gcrossvalidate.m
    3.2KB
  • code_ECOC.m
    5.1KB
  • kpca.m
    6.1KB
  • code_OneVsAll.m
    361B
  • demo_yinyang.m
    3.4KB
  • leaveoneoutlssvm.m
    2.3KB
  • latentlssvm.m
    2.3KB
  • demo_fixedsize.m
    3.2KB
  • postlssvm.m
    4.7KB
  • trainlssvm.m
    8.5KB
  • codelssvm.m
    4KB
  • smootherlssvm.m
    1.1KB
  • trimmedmse.m
    1.7KB
  • lssvmMATLAB.m
    2KB
  • ridgeregress.m
    1.4KB
  • denoise_kpca.m
    3.5KB
  • prelssvm.m
    6.2KB
  • changelssvm.m
    5.4KB
  • bay_rr.m
    4.2KB
  • misclass.m
    684B
  • eign.m
    3.7KB
  • mae.m
    281B
  • crossvalidatelssvm.m
    3.8KB
  • code_MOC.m
    548B
  • demo_fixedclass.m
    2.2KB
  • leaveoneout.m
    3.6KB
  • windowize.m
    1.9KB
  • codedist_bay.m
    2.1KB
  • windowizeNARX.m
    1.8KB
  • rsimplex.m
    9.7KB
  • gcrossvalidatelssvm.m
    2KB
  • crossvalidate.m
    5.7KB
  • tunelssvm.m
    22.2KB
  • roc.m
    7.3KB
  • poly_kernel.m
    623B
  • tbform.m
    3.1KB
  • democlass.m
    3.4KB
  • code.m
    4.1KB
  • robustlssvm.m
    2.1KB
  • progress.m
    1.1KB
  • range.m
    173B
  • initlssvm.m
    3.2KB
  • gridsearch.m
    6.8KB
  • rcrossvalidate.m
    5.8KB
  • demomodel.m
    4.7KB
  • latticeseq_b2.m
    5.7KB
  • linf.m
    310B
  • demomulticlass.m
    2.2KB
  • csa.m
    3.1KB
  • bay_lssvmARD.m
    8KB
  • bay_errorbar.m
    5.6KB
  • simplex.m
    9.6KB
  • simann.m
    5.2KB
  • weightingscheme.m
    928B
  • lssvm.m
    1.7KB
  • democonfint.m
    2.1KB
  • cilssvm.m
    4.6KB
  • predict.m
    3.4KB
  • bitreverse32.m
    1.4KB
  • simlssvm.m
    6.3KB
  • kernel_matrix.m
    3.5KB
  • mse.m
    282B
  • RBF_kernel.m
    1.1KB
  • code_OneVsOne.m
    576B
  • R2006a_R2009a
  • predlssvm.m
    5.2KB
  • lin_kernel.m
    531B
  • plotlssvm.m
    9.7KB
  • rcrossvalidatelssvm.m
    4.1KB
  • demofun.m
    3.9KB
  • linesearch.m
    3.7KB
  • preimage_rbf.m
    4.3KB
  • codedist_hamming.m
    756B
  • bay_modoutClass.m
    9.1KB
  • bay_lssvm.m
    10.1KB
  • bay_optimize.m
    5.7KB
  • medae.m
    311B
  • kernel_matrix2.m
    795B
  • bay_initlssvm.m
    2KB
  • kentropy.m
    2.2KB
内容介绍
function [model,cost,O3] = tunelssvm(model, varargin) % Tune the hyperparameters of the model with respect to the given performance measure % % 1. Using the functional interface: % % >> [gam, sig2, cost] = tunelssvm({X,Y,type,[],[],kernel,preprocess}, optfun, costfun, costargs) % % Outputs % gam : Optimal regularization parameter % sig2 : Optimal kernel parameter(s) % cost(*) : Estimated cost of the optimal hyperparameters % Inputs % X : N x d matrix with the inputs of the training data % Y : N x 1 vector with the outputs of the training data % type : 'function estimation' ('f') or 'classifier' ('c') % kernel(*) : Kernel type (by default 'RBF_kernel') % preprocess(*) : 'preprocess'(*) or 'original' % optfun : Optimization function: 'simplex' or 'gridsearch' % costfun : Function estimating the cost-criterion: 'crossvalidatelssvm', 'leaveoneoutlssvm', 'gcrossvalidatelssvm' % costargs(*) : Cell with extra cost function arguments % % 2. Using the object oriented interface: % % >> model = tunelssvm(model, optfun, costfun, costargs) % % Outputs % model : Object oriented representation of the LS-SVM model with optimal hyperparameters % Inputs % model : Object oriented representation of the LS-SVM model with initial hyperparameters % optfun(*) : Optimization function (by default 'gridsearch') % costfun : Function estimating the cost-criterion: 'crossvalidatelssvm', 'leaveoneoutlssvm', 'gcrossvalidatelssvm' % optfun(*) : Cell with extra cost function arguments % % See also: % trainlssvm, crossvalidate, gridsearch, linesearch, simplex, csa % Copyright (c) 2011, KULeuven-ESAT-SCD, License & help @ http://www.esat.kuleuven.be/sista/lssvmlab if iscell(model), model = initlssvm(model{:}); func=1; else func=0; end % % defaults % if length(varargin)>=1, optfun = varargin{1}; else optfun='gridsearch';end if length(varargin)>=2, costfun = varargin{2}; else costfun ='crossvalidatelssvm'; end if length(varargin)>=3, costargs = varargin{3}; else costargs ={}; end if strcmp(costfun,'crossvalidatelssvm') || strcmp(costfun,'rcrossvalidatelssvm') || strcmp(costfun,'crossvalidatesparselssvm') if size(costargs,2)==1, error('Specify the number of folds for CV'); end [Y,omega] = helpkernel(model.xtrain,model.ytrain,model.kernel_type,costargs{2},0); costargs = {Y,costargs{1},omega,costargs{2}}; end if strcmp(costfun,'crossvalidate2lp1') fprintf('\n') disp('-->> Cross-Validation for Correlated Errors: Determine optimal ''l'' for leave (2l+1) out CV') % if user specifies 'l' if numel(costargs)==1, luser = NaN; else luser = costargs{2};end [l,index] = cvl(model.xtrain,model.ytrain,luser); % First determine the 'l' for the CV fprintf(['\n -->> Optimal l = ' num2str(l)]); fprintf('\n') [Y,omega] = helpkernel(model.xtrain,model.ytrain,model.kernel_type,[],1); costargs = {Y,index,omega,costargs{1}}; end if strcmp(costfun,'gcrossvalidatelssvm') || strcmp(costfun,'leaveoneoutlssvm') [Y,omega] = helpkernel(model.xtrain,model.ytrain,model.kernel_type,[],0); costargs = {Y,omega,costargs{1}}; end if strcmp(costfun,'rcrossvalidatelssvm') eval('model.weights = varargin{4};','model.weights = ''wmyriad''; ') end if strcmp(costfun,'crossvalidatelssvm_SIM') [Y,omega] = helpkernel(model.xtrain,model.ytrain,model.kernel_type,[],1); costargs = {model.xtrain,Y,costargs{1},omega,costargs{2}}; end % change the coding type for multiclass and set default 'OneVsOne' if no % coding type specified %if length(varargin)>=5 && ~isempty(varargin{5}) if model.type(1) =='c' && ~(sum(unique(model.ytrain))==1 || sum(unique(model.ytrain))==0) eval('coding = varargin{4};','coding = ''code_OneVsOne''; ') varargin{5}= coding; model = changelssvm(model,'codetype',coding); [yc,cb,oldcb] = code(model.ytrain,coding); y_dimold = model.y_dim; model.ytrain = yc; model.y_dim = size(yc,2); varargin{end} = []; clear yc end % % multiple outputs if (model.y_dim>1)% & (size(model.kernel_pars,1)==model.y_dim |size(model.gam,1)==model.y_dim |prod(size(model.kernel_type,1))==model.y_dim)) disp('-->> tune individual outputs'); if model.type(1) == 'c' fprintf('\n') disp(['-->> Encoding scheme: ',coding]); end costs = zeros(model.y_dim,1); gamt = zeros(1,model.y_dim); for d=1:model.y_dim, sel = ~isnan(model.ytrain(:,d)); fprintf(['\n\n -> dim ' num2str(d) '/' num2str(model.y_dim) ':\n']); try kernel = model.kernel_type{d}; catch, kernel=model.kernel_type;end [g,s,c] = tunelssvm({model.xtrain(sel,:),model.ytrain(sel,d),model.type,[],[],kernel,'original'},varargin{:}); gamt(:,d) = g; try kernel_part(:,d) = s; catch, kernel_part = [];end costs(d) = c; end model.gam = gamt; model.kernel_pars = kernel_part; if func, O3 = costs; cost = model.kernel_pars; model = model.gam; end % decode to the original model.yfull if model.code(1) == 'c', % changed model.ytrain = code(model.ytrain, oldcb, [], cb, 'codedist_hamming'); model.y_dim = y_dimold; end return end %-------------------------------------------------------------------------% if strcmp(model.kernel_type,'lin_kernel'), if ~strcmp(model.weights,'wmyriad') && ~strcmp(model.weights,'whuber') [par,fval] = csa(rand(1,5),@(x)simanncostfun1(x,model,costfun,costargs)); else [par,fval] = csa(rand(2,5),@(x)simanncostfun1(x,model,costfun,costargs)); model.delta = exp(par(2)); end model = changelssvm(changelssvm(model,'gam',exp(par(1))),'kernel_pars',[]); clear par fprintf('\n') disp([' 1. Coupled Simulated Annealing results: [gam] ' num2str(model.gam)]); disp([' F(X)= ' num2str(fval)]); disp(' ') elseif strcmp(model.kernel_type,'RBF_kernel') || strcmp(model.kernel_type,'sinc_kernel') || strcmp(model.kernel_type,'RBF4_kernel') if ~strcmp(model.weights,'wmyriad') && ~strcmp(model.weights,'whuber') [par,fval] = csa(rand(2,5),@(x)simanncostfun2(x,model,costfun,costargs)); else [par,fval] = csa(rand(3,5),@(x)simanncostfun2(x,model,costfun,costargs)); model.delta = exp(par(3)); end model = changelssvm(changelssvm(model,'gam',exp(par(1))),'kernel_pars',exp(par(2))); fprintf('\n') disp([' 1. Coupled Simulated Annealing results: [gam] ' num2str(model.gam)]); disp([' [sig2] ' num2str(model.kernel_pars)]); disp([' F(X)= ' num2str(fval)]); disp(' ') elseif strcmp(model.kernel_type,'poly_kernel'), warning off if ~strcmp(model.weights,'wmyriad') && ~strcmp(model.weights,'whuber') [par,fval] = simann(@(x)simanncostfun3(x,model,costfun,costargs),[0.5;0.5;1],[-5;0.1;1],[10;3;1.9459],1,0.9,5,20,2); else [par,fval] = simann(@(x)simanncostfun3(x,model,costfun,costargs),[0.5;0.5;1;0.2],[-5;0.1;1;eps],[10;3;1.9459;1.5],1,0.9,5,20,2); model.delta = exp(par(4)); end warning on %[par,fval] = csa(rand(3,5),@(x)simanncostfun3(x,model,costfun,costargs)); model = changelssvm(changelssvm(model,'gam',exp(par(1))),'kernel_pars',[exp(par(2));round(exp(par(3)))]); fprintf('\n\n') disp([' 1. Simulated Annealing results: [gam] ' num2str(model.gam)]); disp([' [t] ' num2str(model.kernel_pars(1))]); disp([' [degree] ' num2str
评论
    相关推荐