码迷,mamicode.com
首页 > Web开发 > 详细

MATLAB时间序列预测Prediction of time series with NAR neural network

时间:2016-05-13 21:56:58      阅读:889      评论:0      收藏:0      [点我收藏+]

标签:

具体请参考:http://lab.fs.uni-lj.si/lasin/wp/IMIT_files/neural/nn05_narnet/

format compact

% data settings
N  = 249; % number of samples
Nu = 224; % number of learning samples

y = Data;% Input your data
% prepare training data
yt = con2seq(y(1:Nu)‘);

% prepare test data
yv = con2seq(y(Nu+1:end)‘);

% Choose a Training Function
% For a list of all training functions type: help nntrain
% ‘trainlm‘ is usually fastest.
% ‘trainbr‘ takes longer but may be better for challenging problems.
% ‘trainscg‘ uses less memory. NTSTOOL falls back to this in low memory situations.
trainFcn = ‘trainlm‘;  % Levenberg-Marquardt

% Create a Nonlinear Autoregressive Network
feedbackDelays = 1:5;
hiddenLayerSize = 40;
net = narnet(feedbackDelays,hiddenLayerSize,‘open‘,trainFcn);

[Xs,Xi,Ai,Ts] = preparets(net,{},{},yt);

% train net with prepared training data
net = train(net,Xs,Ts,Xi,Ai);
% view trained net
% close feedback for recursive prediction
net = closeloop(net);
% view closeloop version of a net
view(net);

%%%Recursive prediction on test data
% prepare test data for network simulation
yini = yt(end-max(feedbackDelays)+1:end); % initial values from training data
% combine initial values and test data ‘yv‘
[Xs,Xi,Ai] = preparets(net,{},{},[yini yv]);

 

MATLAB时间序列预测Prediction of time series with NAR neural network

标签:

原文地址:http://www.cnblogs.com/huadongw/p/5491225.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!