基于LS-SVM工具箱的多输入多…

今天看到这篇博文,觉得不错,因此特地转载过来。

clc ;
clear;
close all
%---------------------------------------------------
% 产生训练样本
xn_train1 = 1:2:200;                  % 训练样本,每一列为一个样本
xn_train2 = 1:1:100;
dn_train1 = xn_train1+2*xn_train2;    % 训练目标,行向量
dn_train2 = 0.5*xn_train1+xn_train2;
% 产生测试样本
xn_test1 = 2:2:200;                   % 测试样本,每一列为一个样本
xn_test2 = 1:2:200;
dn_test1 = xn_test1+2*xn_test2;        % 测试目标,行向量
dn_test2 = 0.5*xn_test1+xn_test2;
%---------------------------------------------------
% 参数设置 (由于lssvm中函数调用X,Y时,默认行是样本个数,列是自变量的个数【即如输入为单变量则列为1,3变量则列为3,所以要做转置)
% 注意看下
% d Dimension of the input vectors
% m Dimension of the output vectors
% N Number of training data
% Nt Number of test data
% X N×d matrix with the inputs of the training data
% Xt Nt×d matrix with the inputs of the test data
% Y N×m matrix with the outputs of the training data
% Yt Nt×m matrix with the outputs of the test data
% 输入:X(100*2),输出Y(100*2),Xt(100*2),Yt(100*2)
X = [xn_train1' xn_train2'];
Y = [dn_train1' dn_train2'];
Xt =[xn_test1' xn_test2'];
Yt = [dn_test1' dn_test2'];
type = 'function estimation';
kernel = 'RBF_kernel';
gam = [9.038e+006 3.7435e+007]; % Regularization parameter
sig2 =[113.67 87357];                 % Kernel parameter (bandwidth in the case of the 'RBF_kernel'
model = initlssvm(X,Y,type,gam,sig2,kernel);                 % 模型初始化
%---------------------------------------------------
% 训练与测试
model = trainlssvm(model);  % 训练
Yp = simlssvm(model,Xt);    % 回归
%---------------------------------------------------
% 结果作图
plot(1:length(Yt),Yt,'r+:',1:length(Yp),Yp,'bo:')
title('+为真实值,o为预测值')

 

我把程序亲自跑了一下,效果图如下:

[转载]基于LS-SVM工具箱的多输入多输出预测仿真
本文转载于http://www.ilovematlab.cn/forum.php?mod=viewthread&tid=177076&highlight=),请尊重作者,支持原创。

 

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值