How can I use neural network time series toolbox to actually make predicts?

조회 수: 5 (최근 30일)
Evan John
Evan John 2017년 5월 1일
댓글: Muhammad Usman Saleem 2023년 5월 14일
I am trying to train a neural network to make predictions about the trajectory of a ball. So I have an excel spreadsheet with about 20 trajectories (time, x, y, z for each of them) and I am trying to train it so that it can predict an entire trajectory based upon the initial condition given to it (initial time is 0 for all of them, as is initial x since they are all starting at the same spot).
I have been doing the following :
nnstart --> Time Series App --> Nar --> Load data --> train.
I create the Matlab Matrix only function and then the simple script. But how can I actually use this to make predictions? All of the manuals and tutorials are very vague at this part. They pretty much show you how to train it and validate that it works on data it hasn't seen, but doesn't actually tell you how to use it to make predictions, even in the examples that it gives. Ideally I would like to give it the initial state (time = 0, x = 0, y = y0, z = z0) and then it populates the rest of the trajectory until it reaches x=10. I can give it data for delay states if needed
Thank you so much!

답변 (1개)

Sanjana Ramakrishnan
Sanjana Ramakrishnan 2017년 5월 3일
Refer the below example code for predicting using Neural Network:
1) Load the simple time-series prediction data and create a NAR network.
T = simplenar_dataset;
net = narnet(1:2,10);
2)Prepare the time series data using preparets and train the network:
[Xs,Xi,Ai,Ts] = preparets(net,{},{},T);
net = train(net,Xs,Ts,Xi,Ai);
3)Calculate the network performance.
[Y,Xf,Af] = net(Xs,Xi,Ai);
perf = perform(net,Ts,Y)
4)To predict the output for the next 20 time steps, first simulate the network in closed loop form.
[netc,Xic,Aic] = closeloop(net,Xf,Af);
5)To simulate the network 20 time steps ahead, input an empty cell array of length 20. The network requires only the initial conditions given in Xic and Aic.
y2 = netc(cell(0,20),Xic,Aic)
  댓글 수: 2
Evan John
Evan John 2017년 5월 5일
Hi, thank you for the help. This works for a single time series set and I can then use it to predict that one perfectly (although, can you explain how Xic and Aic are the initial conditions, when I look at them in my workspace Xic is a 0x0 cell and Aic is a 3x2 cell with only the last row containing non-zero matrices, how exactly are they being used to set the initial condition?) When I try inputting more than one trajectory into the data set, I start running into some problems and the neural network starts "getting stuck" at a certain position (i.e. the trajectory it outputs will have the same position in the last 100 cells, so it's not predicting the entire trajectory).
Can you also explain how the training works exactly? let's say that the first trajectory has an initial condition of (time=0, x=-10, y=0, z=1) and the second trajectory has an initial condition of (time = 0, x=-10, y=0, z=0.4) and each has 100 data points so they are 100x4 arrays in my workspace. In order to train the NN properly, I do not believe that I should simply take the second trajectory and place it at the end of the first one and take that as my input. In other words, my input should not be a 200x4 matrix I do not believe. Rather, they should be inputted as 2, 100x4 data sets each with its own timing, x, y, and z information. Furthermore, then, I would like the neural network to be able to predict the trajectories for intermediate trajectories between the two cases for something like the initial condition (time = 0, x=-10, y=0, z=0.7). This is an interpolation problem rather than an extrapolation one so I believe it is a well-posed problem.
Thank you so much for your help, I know it must be difficult to understand exactly what I am asking so I really appreciate the effort!
Muhammad Usman Saleem
Muhammad Usman Saleem 2023년 5월 14일
Have you find solution to predict fututre 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