最小二乘支持向量机(LS-SVM)工具箱及使用说明

最小二乘支持向量机Matlab工具箱 下载址: 

 http://www.esat.kuleuven.be/sista/lssvmlab 

点击 Latest version: LS-SVMlab v1.8 (August 16, 2011)

有两个版本: Matlab R2006a - R2009a: LS-SVMlab1.8 - Linux and Windows (32 and 64 bit):

                    Matlab R2009b - R2013a: LS-SVMlab1.8 - Linux and Windows (32 and 64 bit):


根据自己Matlab的版本下载,我下载的是第二个“Matlab R2009b - R2013a”,直接进行解压得到文件下“LSSVMlabv1_8_R2009b_R2011a”,就是这样,我的Matlab版本是2012a,可以使用。

下一步,将最小二乘支持向量机Matlab工具箱(LSSVMlabv1_8_R2009b_R2011a)所在的目录添加到Matlab工作搜索目录。

具体操作:在Matlab菜单栏中选择File—>Set Path—>Add with Subfoldders,然后选择LSSVMlabv1_8_R2009b_R2011a文件夹,最后单击 Save就可以了。


1.LS-SVM分类的小例子

clear all
clc;

X = 2.*rand(30,2)-1;
Y = sign(sin(X(:,1))+X(:,2));

gam = 10;
sig2 = 0.2;
type = 'classification';

[alpha,b] = trainlssvm({X,Y,type,gam,sig2,'RBF_kernel'});
%[alpha,b] = trainlssvm({X,Y,type,gam,sig2,'RBF_kernel','original'});
%[alpha,b] = trainlssvm({X,Y,type,gam,sig2,'RBF_kernel','preprocess'});
Xt = 2.*rand(10,2)-1;
disp(' >> Ytest = simlssvm({X,Y,type,gam,sig2,''RBF_kernel'',''preprocess''},{alpha,b},Xt);');
Ytest = simlssvm({X,Y,type,gam,sig2,'RBF_kernel','preprocess'},{alpha,b},Xt);

figure; plotlssvm({X,Y,type,gam,sig2,'RBF_kernel','preprocess'},{alpha,b});
2.LS-SVM回归分析的小例子

clc;

X = (-3:0.2:3)';

eval('Y = sinc(X)+0.1.*randn(length(X),1);',...
     'Y = sin(pi.*X+12345*eps)./(pi*X+12345*eps)+0.1.*randn(length(X),1);');

gam = 10;
sig2 = 0.3;

type = 'function estimation';

[alpha,b] = trainlssvm({X,Y,type,gam,sig2,'RBF_kernel'});
%[alpha,b] = trainlssvm({X,Y,type,gam,sig2,'RBF_kernel','original'});
%[alpha,b] = trainlssvm({X,Y,type,gam,sig2,'RBF_kernel','preprocess'});


Xt = 3.*randn(10,1);

Yt = simlssvm({X,Y,type,gam,sig2,'RBF_kernel','preprocess'},{alpha,b},Xt);

figure; plotlssvm({X,Y,type,gam,sig2,'RBF_kernel','preprocess'},{alpha,b});
hold off
Xt = (min(X):.1:max(X))'; 
eval('Yt = sinc(Xt);',...
     'Yt = sin(pi.*Xt+12345*eps)./(pi*Xt+12345*eps)+0.1.*randn(length(Xt),1);');
hold on;  plot(Xt,Yt,'r-.'); hold off

更详细的讲解参考 文件夹“LSSVMlabv1_8_R2009b_R2011a”下的8个demo:demomulticlass.m、demomodel.m、demofun.m等

和《最小二乘支持向量机工具箱使用指南》

链接:http://download.csdn.net/detail/u012507022/9473214


相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页