我目前正在使用神经网络,我还是初学者.我的目的是使用MLP来预测流量时间序列(我知道,NARX网络可能更适合时间序列预测,但要求是MLP).
例如,我想用当前和历史流量Q(t … t-n)和降水量P(t … t-m)等预测流量Q(t x).
我的网络培训(网络的培训,验证和测试)和额外的验证期的结果显示了相对较好的质量(相关性和RMSE).但是,当我仔细观察训练和验证期的输出时,各个周期的目标存在滞后.我的问题是我不知道为什么.
滞后完全对应于我的预测期x,无论x多大.
我使用Matlab工具箱中的标准MLP和默认设置(随机分割,trainlm等),比如使用图形NN工具(但我也用我自己的代码测试了其他设置).
使用简单的Q(t)NAR-net就是同样的问题.如果我用常规数据来测试,例如用sin(t..t-n)预测sin(t x)或用矩形函数预测sin(t x)没有时移,那一切都很好.
只有当我使用真实世界数据或不规则(但最常量)的数据时,如[0.12 0.14 0.13 0.1 0.1 0.1 …(n次)0.1 … 0.1 0.1 0.14 0.15 0.12 ……]目标之间存在转换和输出.虽然我用目标Q(t x)训练网络,但实际训练输出是Q(t).我还尝试了一些其他输入变量组合,从少到多的信息.我的时间序列是7年以上,每小时分辨率.但它也会与其他决议一起出现.
在我的工作中有什么我错的或我能尝试的东西.我读过其他一些人也有这个问题,但没有解决方案?我认为这不是我的实现失败,因为我也尝试了matlab工具和窦功能,并且有相同的结果.如果我忽略了这种转变,那么值的准确性也不错(这就是为什么相关性和rmse的优点也很明显).
我用matlab 2012.
这里也是一个简约的代码示例,只有最重要的导入点.但也很好地说明了问题.
%% minimalstic example
% but there is the same problem with more input variables
load Q
%% create net inputs and targets
% start point of t
t = 100;
% history data of Q -> Q(t-1), Q(t-2), Q(t-3)
inputs = [Q(t-1:end-1,1) Q(t-2:end-2,1) Q(t-3:end-3,1)]';
% timestep t that want to be predicted
targets = Q(t:end,1)';
%% create fitting net (MLP)
% but it is the same problem for NARnet
% and from here, you can also use the NN graphical tool
% number of hidden neurons
numHiddenNeurons = 6; % the described problem is not dependent on this
% point, therefor it is freely chosen
net = fitnet(numHiddenNeurons); % same problem if choosing the old version newfit
% default MLP settings, no changes, but the problem even exist with other
% combinations of settings
% train net
[trained_net,tr] = train(net,inputs,targets);
% apply trained net with given data (create net outputs)
outputs = sim(trained_net,inputs);
figure(1)
hold on
bar(targets',0.6,'FaceColor','r','EdgeColor','none')
bar(outputs',0.2,'FaceColor','b','EdgeColor','none')
legend('observation','prediction')
% please zoom very far to see single bars!! the bar plot shows very good
% the time shift
% if you choose a bigger forecasting time, the shift will also be better to
% see
%% the result: targets(1,1)=Q(t), outputs(1,1)=Q(t-1)
%% now try the sinus function, the problem will not be there
x = 1:1:1152;
SIN = sin(x);
inputs = [SIN(1,t-1:end-1);SIN(1,t-2:end-2);SIN(1,t-3:end-3)];
targets = SIN(1,t:end);
% start again from above, creating the net
我没有足够的声誉上传两个代码结果的摘录,提前一步预测.