Matlab中libsvm回归怎么做时间序列的单步和多步预测
发布网友
发布时间:2022-04-21 22:30
我来回答
共2个回答
热心网友
时间:2023-10-05 09:11
您好,很高兴为您解答。
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
如若满意,请点击右侧【采纳答案】,如若还有问题,请点击【追问】
希望我的回答对您有所帮助,望采纳!
~ O(∩_∩)O~
热心网友
时间:2023-10-05 09:12
使用符号运算符 | 或者命令or
比如:
lgc1=ture;
lgc2=false;
lgc1 | lgc2
lgc1 | lgc1
or(lgc1,lgc2)