Time series prediction using NARX Net ( nnstart toolbox), can predictions be made without depending output after training has been done ?

2 次查看(过去 30 天)
so i have trained a narx net using nnnstart command, but there is a issure i a m facing that , it is predictiong output(Y_new) for new dataset only if we provide target output data(t_new) in preparets function , i.e to be excecuted just before making final prediction? on executing [Xs,Xi,Ai] = preparets(net,x_new,{}); , i am getting NaN for Y_new( predicted output) . but if i run [Xs_new,Xi_new,Ai_new,Ts] = preparets(net,x_new,{},t_new); , it is predicting , meanining it is dependent on target data. how to solve this issue? bcoz in reality we dont know target values that is why we are predicting ryt?
[net,tr] = train(net,Xs,Ts,Xi,Ai); % trained network using narxnet
[Xs,Xi,Ai] = preparets(net,x_new,{}); % prepare time series data - option 1 ( not working)
[Xs_new,Xi_new,Ai_new,Ts] = preparets(net,x_new,{},t_new); % prepare time series data - 2 ( working)
Y_new = net(Xs_new,Xi_new,Ai_new); % prediction on New Data set
  1 个评论
Thushar
Thushar 2024-5-18
below is the code for training using narx netowrk ( i have a non linear dataset) , can someone help me write the code for predicting for new data set using the trained nework net and final layer states? i have given many trials, but was unsuccesfull.
XTrain = tonndata(Predictors_train,false,false); % input for training
TTrain = tonndata(Responsers_train,false,false); % output for training
XPredict = tonndata(Predictors_test, false, false); % input for prediction ( new dataset for testing trainied network)
TTarget =tonndata(Responsers_test,false,false); % corresponding output -new dataset - (in reality it will be unkown)
net = narxnet(1:2,1:2,10);
% view(net);
[Xs,Xi,Ai,Ts] = preparets(net,XTrain,{},TTrain);
net = train(net,Xs,Ts,Xi,Ai);
[Y,Xf,Af] = net(Xs,Xi,Ai);
perf = perform(net,Ts,Y);
Y_mat = (cell2mat(Y))';
Ts_mat = (cell2mat(Ts))';
figure;
plot(Y_mat,'r', 'linewidth',1.2);
hold on;
plot(Ts_mat,'b','linewidth',1.2);
%% Prediction on new data set using the trained network

请先登录,再进行评论。

回答(1 个)

Neha
Neha 2024-5-17
Hi Thushar,
For a NARX network, during training, the network learns to predict the current target (t) based on past values of the target and past values of the inputs (x). This means the network inherently relies on having access to past target values during prediction as well.
When preparing your dataset, you can partition it into training data (XTrain and TTrain) for model training, and separate data (XPredict) for making predictions. Please refer to the following documentation link for more information on training a NARX Network and predicting on new data:
  1 个评论
Thushar
Thushar 2024-5-18
Thank you for your support :) , i tried the way you said but its working well till validation and for new data not some eror occuring ( NaN for predicted values) .

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by