Is my neural network also using testing data to predict and not only the training and validation data?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I made a neural time series analysis similar to the default one in the nnstart wizard. The only change I made to the code was to use divideblock instead of dividerand for my data to be divided into blocks. I have my time series analysis use the earliest data as training, then later data as validation, and finally the latest data as testing, which is why I used divideblock instead of dividerand. Using dividerand would scatter testing targets throughout the time frame rather than at the very end. I'm more interested in seeing if it can make accurate test outputs after the last training data point rather than between two training points.
Out of the 7000+ input data points, I set my training + validation to the first 99.8% of data and my test to the last 0.2% since I only want to see how well it can predict in the future short term (only 14 data points ahead). The results looked okay. I wanted to test the data manually to make sure it wasn't using the test data to learn even though the tutorial stated the test data was independent. The exact words of the tutorial for test data: "These have no effect on training and so provide an independent measure of network performance during and after training."
I set my last 4 data inputs to 0 (normally would be in the thousands like almost all the inputs prior). So the first 10 values of my test data were normal (in the thousands) and the very last 4 were set to 0. I ran the code and data returned the model showing the last 4 test outputs were now fitted to fall to 0 by the end. I went back and set them to their normal values (in the thousands) and ran it and the test outputs were nearly spot on (in the thousands) and not falling to 0 like they were the other runs.
If the test targets were truly independent of the training and validation data, how is this happening? Every time I ran it with the last 4 test targets at 0, the test outputs drop to 0. If they were reset to their normal values, they would be again almost spot on. To me, that means it's using the test set as part of training or at the very least using the most recent test target to make make the next test output (as if to correct a mistake if it was way off on the last data point prediction). Is there something I'm missing? Are the test targets being used incrementally for the next test output if it gets it wrong or is it being used in the training set somehow? How can I set it to completely ignore test targets in making a test output?
Edit: Screenshot of graph attached.
0 Commenti
Risposte (2)
Greg Heath
il 25 Giu 2017
Modificato: Greg Heath
il 12 Lug 2017
1. a. I'm glad that you agree with me that DIVIDEBLOCK should be the default for time series prediction ( search NEWSGROUP and ANSWERS with GREG DIVIDEBLOCK ).
b. The current default of DIVIDERAND is obviously only good for interpolation.
c. I disagree with you w.r.t. the test subset data being involved in training.
It definitely should not be. You can prove this by replacing the entire the
test subset with zeros and setting the rng to the same initial state. You
should get the same weight values.
2. You have provided insufficient information. It is very rare that someone can get their point across clearly without posting code with comments.
3. You use the word input. I hope you are using NARNET for which there is no applied input. Otherwise things don't make sense.
4.
[ I N ] = size(input) = ?
[ O N ] = size(target) = ?
ID = input delays = ?
FD = feedback delays = ?
H = No. of hidden nodes = ?
[ Ntrn Nval Ntst]/N = 0.7/0.15/0.15 ?
5. What is the data point number for the 1st test point?
6. Please post your code.
Hope this helps.
Greg
3 Commenti
Greg Heath
il 26 Giu 2017
Modificato: Greg Heath
il 26 Giu 2017
Thanks for the detail. I will read it ASAP.
Unfortunately my computer was sick and I lost my MATLAB code. So far I haven't been able to load the replacement yet. Hope to get to it this week.
UGH ...
The code produced by nnstart is NEVER recommended to newbies by me. It is too voluminous and doesn't emphasize the important points. For example: First there is a long explanation paragraph; then there is code that just assigns default values.
The code produced by the help and doc commands is SHORT and ALMOST SWEET.
help narnet
doc narnet
I explain the "ALMOST" in my recent SHORT & SWEET (;>) QUICKIES post
https://www.mathworks.com/matlabcentral/newsreader/view_thread/348883#954773
Later,
Greg
Greg Heath
il 26 Giu 2017
1. YOUR EXPERIMENT IS FAULTY
2. The basic assumption of NN learning is that the training, validation, and test subsets have similar summary secondary statistics:
mean, standard deviation and correlation function.
3. Obviously your test subset has a different mean.
4. In addition, if the training subset has no variance, the function can be modeled with zero value weights: the output can be soley created with the biases.
5. One way to prove that the test set does not affect learning is
a. Use the example data in the documentation
i) help narnet
ii) doc narnet
b. Assign an initial state to the RNG (e.g., RNG(0))
c. Design net1 with the documentation code in a
and DIVIDEBLOCK
d. Reassign the same initial RNG state as in a
e. Design net2 with DIVIDEBLOCK and Ntst = 0
f. Compare the two sets of weights and biases.
6. I have not demonstrated this. However, if you have the time ... (;>)
Hope this helps.
Greg
Vedere anche
Categorie
Scopri di più su Signal Modeling in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!