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

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

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


08-08

12-05 6317
07-05
11-17
03-29 5147
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客