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

clc ;
clear;
close all
%---------------------------------------------------
% 产生训练样本与测试样本
xn_train1 = 1:2:200;                % 训练样本,每一列为一个样本
xn_train2 = 1:1:100;
dn_train = xn_train1+2*xn_train2;      % 训练目标,行向量
xn_test1 = 2:2:200;                 % 测试样本,每一列为一个样本
xn_test2 = 1:2:200;
dn_test = xn_test1+2*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*1),Xt(100*2),Yt(100*1)
X = [xn_train1' xn_train2'];
Y = dn_train';
Xt =[xn_test1' xn_test2'];
Yt = dn_test';
type = 'function estimation';
kernel = 'RBF_kernel';
gam = 602572453.6492 ;                   % Regularization parameter
sig2 = 329.5513877868;                 % 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=),请尊重作者,支持原创。

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值