楼主: miokong
10100 2

[问答] 跪求MATLAB 神经网络预测 已贴程序,求解 [推广有奖]

  • 0关注
  • 0粉丝

已卖:230份资源

大专生

63%

还不是VIP/贵宾

-

威望
0
论坛币
270 个
通用积分
0.0600
学术水平
5 点
热心指数
6 点
信用等级
5 点
经验
851 点
帖子
47
精华
0
在线时间
34 小时
注册时间
2006-12-10
最后登录
2014-10-6

楼主
miokong 发表于 2014-9-2 22:13:41 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

请问在时间序列数据上怎样预测呢? (如图)

question.PNG

已知x1,x2…为输入变量, x3为输出变量

训练和测试的比例为80/20

当训练完成后要做预测(比如预测之后10个数值), 请问matlab怎样做到?


附上程序, 差最后预测步骤, 求解

  1. inputSeries = tonndata(time_in,true,false);
  2. targetSeries = tonndata(time_out,true,false);

  3. % Create a Time Delay Network
  4. inputDelays = 0:1;
  5. hiddenLayerSize = 10;
  6. net = timedelaynet(inputDelays,hiddenLayerSize);


  7. net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
  8. net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};

  9. [inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,targetSeries);


  10. net.divideFcn = 'divideblock';  % Divide data randomly
  11. net.divideMode = 'time';  % Divide up every value
  12. net.divideParam.trainRatio = 80/100;
  13. net.divideParam.valRatio = 20/100;
  14. net.divideParam.testRatio = 0/100;


  15. net.trainFcn = 'trainlm';  % Levenberg-Marquardt
  16. net.performFcn = 'mse';  % Mean squared error


  17. % Choose Plot Functions
  18. % For a list of all plot functions type: help nnplot
  19. net.plotFcns = {'plotperform','plottrainstate','plotresponse', ...
  20.   'ploterrcorr', 'plotinerrcorr'};


  21. % Train the Network
  22. [net,tr] = train(net,inputs,targets,inputStates,layerStates);

  23. % Test the Network
  24. outputs = net(inputs,inputStates,layerStates);
  25. errors = gsubtract(targets,outputs);
  26. performance = perform(net,targets,outputs)

  27. % Recalculate Training, Validation and Test Performance
  28. trainTargets = gmultiply(targets,tr.trainMask);
  29. valTargets = gmultiply(targets,tr.valMask);
  30. testTargets = gmultiply(targets,tr.testMask);
  31. trainPerformance = perform(net,trainTargets,outputs)
  32. valPerformance = perform(net,valTargets,outputs)
  33. testPerformance = perform(net,testTargets,outputs)

  34. % View the Network
  35. view(net)

  36. % Plots
  37. % Uncomment these lines to enable various plots.
  38. figure, plotperform(tr)
  39. figure, plottrainstate(tr)
  40. figure, plotresponse(targets,outputs)
  41. figure, ploterrcorr(errors)
  42. figure, plotinerrcorr(inputs,errors)
复制代码




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB matla atlab 神经网络 Mat 程序 网络

沙发
miokong 发表于 2014-9-3 10:39:18
上网找到了以下答案, 请问各位有没有明白以下是甚么意思, 看不懂...

动态时间序列神经网络的预测分成两种情况:

1:循环预测

这种预测非常符合我们的思考方式,毕竟网络的输出是依赖于当前和(或)过去的输入输出,那么同样,y(t+2)是依赖于y(t+1)的,所以循环预测是大家都能接受的方式!

for k=1:2,
  Ai1{1,k}=zeros(10,1);
  Ai1{2,k}=y1{k};
end
for k=1:2,
  Pi1{1,k}=u1{k};
end
yp1 = sim(narx_net_closed,p1,Pi1,Ai1);


2:一次性预测

这种预测方式是Matlab所独特的,因为matlab提供了相应的函数,帮你把数据进行了shift,

[p1,Pi1,Ai1,t1] = preparets(narx_net_closed,u1,{},y1);
yp1 = narx_net_closed(p1,Pi1,Ai1);
plot([cell2mat(yp1)' cell2mat(t1)'])

藤椅
SophiaHanx 发表于 2017-12-9 21:37:24
请问解决了吗,我也遇到这个问题了。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 10:55