how to predict the values at future timesteps in matlab ntstool - matlab

I have to use NAR network to train a time-series for my project. To have an idea of how time-series tool (ntstool) works in MATLAB , I used the GUI of ntstool in matlab with a dataset containing 427 timesteps of one element. While training I used a neural network with 10 hidden layers and delay value = 5.
Now I have following Three questions :
What does the **delay value (d) ** in the GUI means. Does it mean that while training the network assumes that each timestep value is dependent on last 'd' timesteps' values ?
how to predict the values at future timesteps in ntstool?

Delay value means that neural network inputs are current input value and N delay values of input signals, in your case N=5. Hope this will help you.

Related

Autoencoder in MATLAB

My goal is to train an Autoencoder in Matlab. I am using the Deep Learning Toolbox. I am new to both autoencoders and Matlab, so please bear with me if the question is trivial.
My input datasets is a list of 2000 time series, each with 501 entries for each time component. So my input dataset is stored into an array called inputdata which has dimensions 2000*501.
The autoencoder should reproduce the time series. Thi means the output should be 2000 times a time series of 501 components. So, my understanding is that the input nodes should be 501 and the same should be true for the output nodes.
However, if I do:
hiddenSize = 100;
autoenc = trainAutoencoder(y_sorted,hiddenSize);
to train an autoencoder with 100 nodes in the hidden layer, I think the Autoencoder automatically chooses to have 2000 input nodes. What is the correct way of training this Autoencoder?
Hi I haven't tried to train an autoencoder myself with the Deeplearning toolbox, but as far as i can read here (https://www.mathworks.com/help/deeplearning/ref/trainautoencoder.html?s_tid=doc_ta) your input matrix should have the samples as columns and the features/values of your timeseries in the rows. You can do this easy by transposing your input matrix. In MATLAB this is done by:
inputdata = inputdata.'

Neural Network Multiple Inputs and one output

i want to create a Neural Network with "three (2D) Matrices" as a inputs , and
the output is a 1 (2D) Matrix , so the three inputs is :
1-2D Matrix Contains ( X ,Y ) Coordinates From a device
2-2D Matrix Contains ( X ,Y ) Coordinates From another different Device
3-2D Matrix Contains the True exact( X , Y ) Coordinates that i already
measured it ( i don't know if that exact include from the inputs or What??)
***Note that each input have his own Error and i want to make the Neural Network
to Minimize that error and choose the best result depends on the true exact (X,Y)***
**Notice that : im Working on object tracking that i extracting (x,y) Coordinate
from the camera and the other device is same the data so for example
i will simulate the Coordinates as Follows:
{ (1,2), (1,3), (1,4), (1,5) , (1,6).......}
and so on
For Sure the Output is one 2D Matrix the best or the True Exact (x,y) ,So im a
beginner and i want to understand how to create this Network with this Different
inputs and choose the best training method to have the Best Results ...?!
thanks in Advance
It sounds like what you want is a HxWx2 input where the first channel (depthwise layer) is your 1st input and the 2nd channel is your 2nd input. Your "true exact" coordinates would be the target that your net output is compared to, rather than being an input.
Note that neural nets don't really handle regression (real-valued outputs) very well - you may get better results dividing your coordinate range into buckets and then treating it as a classification problem instead (use softmax loss vs regression mean-squared error loss).
Expanding on the regression vs classification point:
A regression problem is one where you want the net to output a real value such as a coordinate value in range 0-100. A classification problem is one where you want the net to output a set of propabilities that your input belongs to a given class it was trained on (e.g. you train a net on images belonging to classes "cat" "dog" and "rabbit").
It turns out that modern neural nets are much better at classification than regression, because the way they work is basically by subdividing the N-dimensional input spaces into sub-regions corresponding to the outputs they are being trained to make. What they are naturally doing is classifying.
The obvious way to turn a regression problem into a classification problem, which may work better, is to divide your desired output range into sub-ranges (aka buckets) which you treat as classes. e.g. instead of training your net to output a single (or multiple) value in range 0-100, instead train it to output class probabilities representing, for example, each of 10 separate sub-ranges (classes) 0-9, 10-19, 20-20, etc.

How to predict temperature for the 4th day, given temperatures for previous days, using a linear perceptron?

I have four sets of data (3 for training, 1 for testing) that include the hour of the day and temperatures in this format:
Time | Temperature
5, 60
6, 63
7,70
8,73
9,78
10,81.5
11,85.1
12,87
13,90
I need to train and test a perceptron and then predict what the temperatures will be on the next day at the same hours.
I am trying to use Matlab to do this and I know I am supposed to normalize the data and use time-series prediction. However I can't figure out how to start.
I don't understand what the inputs and outputs are, and what activations function to use to make the output linearly from -infinity to +infinity.
I'm pretty sure you won't have to use a perceptron for this task as you want to perform regression and not classification. (Perceptron is a binary classifier see Matlab documentation.)
To start with normalization: You need to adjust your data such that the mean is zero and the standard deviation equals 1. For example:
data = rand(1,100);
data = (data - mean(data))/sqrt(var(data));
You can interpret your input and output as follows:
You have an underlying function which maps your time-values to the temperature values (f:time->temperature). Time is the independent variable and temperature the dependent variable (see for example Wikipedia). And you want to find an approximation for f based on your input data.
For time series regression you will find a detailed example here. If you
are required to use a feedforward network you can also take a look at this.

Simulink neural network data input

I have a 2x147 matrix as an input and a 3x147 matrix as an output, and I trained the NN pattern recognition with the input matrix and output matrix. I then generated a Simulink model of the trained NN, and now I want to test the new dataset of same size (2x147).
I am getting the following errors:
Error in port widths or dimensions. Output port 1 of NN_Trail/Constant is a [2x147] matrix.
Error in port widths or dimensions. Input port 1 of NN_Trail/Pattern Recognition Neural Network is a one dimensional vector with 2 elements.
If I give a constant value of 2 elements, then the Simulink runs for the mentioned time and gives the desired output. How can I get it to work with the data I've described?
My idea in future is to connect the trained neural network to a simulated plant and find the abnormal data from the plant.
So your model has an input of dimenstion 2 and an output of dimenson 3.
And you have an calculated signal of 147 timesteps that you want to run on the inputs.
To import that signal to your model you can use a Matlab time series object.
http://ch.mathworks.com/help/simulink/ug/importing-matlab-timeseries-data-to-a-root-level-input-port.html

How to use trained neural network to predict future values of time series?

I have been using neural network toolbox (MATLAB) for time series prediction. I have followed every step given in the help manual and finally I have got a "net" network.
My input had 1344 values, but the output has 1340 values (because of the delay was 4). But my question is that how do I know the 1341th value and so on using the trained neural network?
This might help
net = newff(observations,targets,10);
[net,tr] = train(net,observations',targets');
erg = zeros(size(test_mat,1),1);
for i = 1: size(test_mat,1)
y = sim(net,test_mat(i,:)');
erg(i)=find(compet(y));
end
where observations is your training set targets are the known values of the hindcast and test_mat are the values for the forecast. In erg the predictions for the forecast are stored.