NeuroLab: What are NeuroLab.Input/Output used for?
Author: SimhaD04
Creation Date: 1/8/2016 10:54 AM
profile picture

SimhaD04

#1
I am learning to use NeuroLab. I started with the sample RSI Periods indicator from the Sample Networks section. The indicator seems to define several RSI indicators of 5, 10, 15, 20, and 25 day periods (as per Input Script). That much is clear. The next step there is to produce NeuroLab.Input as a function of those RSI inputs. What is it? a fit to the 5 specified RSIs, i.e. one function which is in some sense the best fit to those 5?

In the Output Script it uses the function generated in Input to, according to Help, "predict profit after 5 bars". First it seem to simply compute that profit/loss in percent for each 5 bars, assign it to some data series ds and then feed it into the NeuroLab.Output. What specifically does NeuroLab.Output do?

If I can find an explanation to the above questions, I probably can figure how one can use indicators produced by NeuroLab. Or, if it is simpler, if you have an example of using the sample RSI indicator from NeuroLab in a rule-based code, that might also do the job. I know the mechanics of it, i.e. how to place NeuroLab indicators in the code.

Thanks
profile picture

Eugene

#2
QUOTE:
NeuroLab.Input as a function of those RSI inputs. What is it?
What specifically does NeuroLab.Output do?

The concept of input/output scripts is explained in the same User Guide > Neuro-Lab® > Defining a Neural Network > "Input Script" and "Output Script".
profile picture

LenMoz

#3
Arik,

I jumped to the end. Here's a script that trades a neural network... The principle is to buy when the neural network score rises above a value, then sell when the score drops below a second value. A second sell rule sells blindly after a number of bars.

The script uses three parameters, 1. minimum score to buy, 2. lower limit of score to sell, and 3. number of bars. This last parameter specifies when to sell if the lower limit isn't reached. My optimized values, 47.2,37.2, and 29, will not work for you because our neural networks were trained differently. It may be useful to look at a few symbols' charts to set your parameter ranges.

A 9 year backtest using the Dow 30 achieved 13.22% APR vs 9.33 BH.

Len

CODE:
Please log in to see this code.
profile picture

LenMoz

#4
Arik,

How do the input and output scripts work?

Training:
The input script defines the independent variables, fed to training as DataSeries. The output script defines one DataSeries, the dependent variable. Training does a best fit, least error, of calculating the dependent variable from the independent variables. It saves the calculated weights. So much for training.

Script usage:
When using the neural network in a backtest, the input script is run again, at the call to NNIndicator.Series. It develops and uses the input script's DataSeries and the weights produced by training to calculate a prediction DataSeries (dsNN in the post #3 sample script). dsNN is used in the script for buy/sell logic. The output script is not used when backtesting.

Len
profile picture

SimhaD04

#5
Over the weekend I figured what it is doing and was about to start programming. Fortunately I logged on to see the board and saw your comments. Very helpful, thank you, Len. I will play with it over the next few days and will get back if questions/problems.

Arik
profile picture

SimhaD04

#6
Eugene - I slightly modified the sample RSI Periods network by using 5 RSIs but of different from the sample duration: 2, 7, 12 etc. The rest is identical. Now I get Training Error message every time I time try to train it. The error pops at different Epoch numbers, typically between 1,500 - 2,500.

What can I do to fix it? Thanks.
profile picture

Eugene

#7
What was the modification (exact code) and how can this error be reproduced (data, settings)?
profile picture

SimhaD04

#8
In case I inadvertently changed something in Network Topology, here are my settings:

Training Rate: 0.2
Momentum: 0.1
Input Layer Neurons: 5
Output Layer neurons: 1
Hidden Layer: 1 layer with 6 neurons.

Input Script:
CODE:
Please log in to see this code.


Output Script: default, never touched it.

Select Training data page: picked SPY and used default settings in the Data Selection section:
Training Period: first 30% of data
Load every 1 bar for Pattern Training
Lead Bars: 50, End Bars: 5

Next pressed Apply Training Set to get Statistics.

Next went to Train Network, used defaults for Autostop (checked to stop after 500), AutoClear (unchecked), Show Each 1 epoch and clicked Begin Training.

It runs every time for a different number of epochs and stop with Training Error.

Thanks.
profile picture

Eugene

#9
Perhaps it stops after not reaching another 500-epoch low as intended. Any chance you're confusing the message with the "Training Error" chart header? If the network trained and locked you can use it.
profile picture

SimhaD04

#10
You are right, it is indeed the chart header. I noticed it only after the chart stopped; apparently the problem was in the checked AutoStop box, not in any other errors. Thanks, Eugene.
profile picture

SimhaD04

#11
It'd be interesting to assess relative importance of input factors. Is there a way to see/output values of weights computed by the network after training, that is w_ij in figure on the Train Network page of Help?
profile picture

Eugene

#12
Check out Cone's reply #4 in this thread:

Neuro-Lab: Contribution of individual input.
profile picture

SimhaD04

#13
thanks, Eugene, got it.

When I create a new NN indicator, and then use Save As I can see that it creates a corresponding .xml with the assigned name. However, I don't see a new indicator in the NeuroLab folder of the Technical Indicators window (the one that lists Community Indicators, Wealth-Lab Standard Indicators, etc). Under NeuroLab it lists only one NNindicator indicator, even though I saved mine as something like XYZ.
profile picture

LenMoz

#14
Your network is named in the call to NNIndicator. "XYZ" would replace "RSI Periods", in your example.

CODE:
Please log in to see this code.
profile picture

Eugene

#15
Arik,

Now that you figured out the answer to your original question "What are NeuroLab.Input/Output used for?", let's not pack all NL-related questions you may have into this thread.

We try to keep the forum organized and easy to search. As a rule of thumb, it's a good idea to either reuse a more general discussion or start a new properly named one if you wish to get answers to a group of related questions. Or use one thread to keep the discussion focused on a particular problem until it's resolved.