作业帮 > 综合 > 作业

Matlab中libsvm回归怎么做时间序列的单步和多步预测

来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/04/29 11:42:41
Matlab中libsvm回归怎么做时间序列的单步和多步预测
Matlab中libsvm回归怎么做时间序列的单步和多步预测
很高兴为您解答.

a(1)=0;
for i=2:220
  a(i)=0.6*a(i-1)+randn;
end

train_t = 1:200;
train = a(train_t);
train_t = train_t';
train = train';

test_t = 1:203;
test=a(test_t);
test_t = test_t';
test = test';

[bestmse,bestc,bestg] = SVMcgForRegress(train,train_t,-3,11,-7,1,3,0.5,0.5,0.1);
cmd = ['-c ',num2str(bestc),' -g ',num2str(bestg),' -p 0.01 -s 3'];

model = svmtrain(train,train_t,cmd);
[trainpre,trainmse] = svmpredict(train,train_t,model);

figure;
hold on;
plot(train);
plot(trainpre,'r');
title('原来的训练数据的拟合1-200');
legend('原来的训练数据','训练数据预测拟合数据');
hold off

[testpre,testmse] = svmpredict(test,test_t,model);
figure;
hold on;
plot(test);
plot(testpre,'r');
title('测试数据的预测1-203');
legend('测试数据','测试数据预测拟合数据');
hold off

如若满意,请点击右侧【采纳答案】,如若还有问题,请点击【追问】

希望我的回答对您有所帮助,