【问题标题】:Predicting time-series Y (t+1) with Neural Networks in Matlab在 Matlab 中使用神经网络预测时间序列 Y (t+1)
【发布时间】:2017-06-20 04:48:19
【问题描述】:

我有一个数据集,我分成:

  • 训练:预测变量 X_TR(14 个变量中的 1028 条记录)和 Y_TR(1028 条单变量记录)
  • 应用程序:X_APP (115 x 14)、Y_APP (115x1)、

其中每条记录都是一个时间步长 t。

我的目标是构建一个 NN 模型,该模型使用直到 t 的任何历史信息来预测 Y(t+1),即 Y(T+1) = f(X(t),X(t- 1),...,Y(0),X(t),X(t-1),...,Y(0))。请注意,考虑不超过 10 个时间步长的信息是合理的。 根据 mathworks.com/help/nnet/gs/neural-network-time-series-prediction-and-modeling.html,我使用 X_T 和 Y_T 训练了一个 NN。

% Cell arrays inputs for NN
X = tonndata(X_TR,false,false);
T = tonndata(Y_TR,false,false); %output volumes

% training function
trainFcn = 'trainlm';  % Levenberg-Marquardt

% Create NARX
% network parameters
lags = 10;
inputDelays = 1:lags;
feedbackDelays = 1:lags;
hiddenLayerSize = 40;
% construct  NARX net
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);

%prepare time series
[x,xi,ai,t] = preparets(net,X,{},T);

% Training, Validation, Testing
net.divideParam.trainRatio = 60/100;
net.divideParam.valRatio = 20/100;
net.divideParam.testRatio = 20/100;

% Train the Network
[net,tr] = train(net,x,t,xi,ai);

我不知道如何应用经过训练的模型。假设训练成功,我想将模型应用于数据 X_APP 和 Y_APP 的另一部分,以便预测 Y_APP(t+1)。我该怎么做?

谢谢。

【问题讨论】:

    标签: matlab neural-network time-series forecasting autoregressive-models


    【解决方案1】:

    您可以按照以下说明使用经过训练的网络:

    % define your new input
    X = tonndata(X_APP, false, false);
    T = tonndata(Y_APP, false, false);
    
    % prepare new data for usage with your net
    [x,xi,ai,t] = preparets(net,X,{},T);
    
    % generate output
    y = network(x,xi,ai);
    

    您也可以随时保存网络并将其加载回 matlab:

     goodworkingnet = net;
     save goodworkingnet
    

    【讨论】:

      猜你喜欢
      • 2013-02-22
      • 2013-01-15
      • 2014-07-02
      • 2014-05-25
      • 1970-01-01
      • 2013-01-17
      • 1970-01-01
      • 2011-05-12
      • 2015-10-12
      相关资源
      最近更新 更多