Pythia
Pythia
- 11/28/15 - 6:44 PM
1 of 29 pages
During the reproduction phase the networks parameters are not changed anymore and
the network is used for the reproduction of input data in order to predict suitable output
data.
Picture 1 shows a typical Backpropagation Network. It has 2 inputs and 1 output. It
contains two layers (levels) of neurons, level 1 with 2 neurons and level 2 with 1 neuron.
In Backpropagation
Networks each neuron
has one output and as
many inputs as neurons in
the previous level.
Each network input is
connected to every
neuron in the first level.
Each neuron output is
connected to every
neuron in the next level.
- 11/28/15 - 6:44 PM
2 of 29 pages
The network is processed from the left to the right. Picture 2 shows a sample how the
output of a Neural Network is calculated from the input.
Pythia allows you to import data from different file formats or from spreadsheet
programs like Microsoft Excel. You can design and train Neural Networks. Both, data
and networks can easily be stored on disk.
- 11/28/15 - 6:44 PM
3 of 29 pages
Pattern 1
Pattern 2
Pattern 3
Pattern 4
Input 1
0
0
1
1
Input 2
0
1
0
1
Output
0
1
1
0
- 11/28/15 - 6:44 PM
4 of 29 pages
- 11/28/15 - 6:44 PM
5 of 29 pages
Picture 7 The pattern set data have been pasted into a new table
You see the columns I1, I2 and O1. The columns O1(NET) and (SQ DV) are empty
because they are filled later by the Neural Network we will design now.
It is a good idea to save the pattern set under the name XOR.PAT now.
- 11/28/15 - 6:44 PM
6 of 29 pages
Select NETCREATE
NET
- 11/28/15 - 6:44 PM
7 of 29 pages
Select NETREPRO
PATTERN SET
It is the goal of the training phase to minimize these values. When you look at the desired
outputs in column O1 you will see that the output is either 0 or 1. Consequently a
- 11/28/15 - 6:44 PM
8 of 29 pages
O1(NET) value of <0.5 will be sufficient for 0 and a value >0.5 will be sufficient for 1.
This means the deviation for each reproduced pattern must be <0.5, meaning the square
of this deviation must be < 0.25.
Lets setup a learn plan.
Select NETLEARN
PATTERN SET
- 11/28/15 - 6:44 PM
9 of 29 pages
Date
Open
High
Low
Close
Volume
1/4/99 9184.01 9350.33
9122.47 9184.27
883
1/5/99 9184.78 9338.74
9182.98 9311.19
779
1/6/99 9315.42 9562.22
9315.42 9544.97
986
1/7/99 9542.14 9542.14
9426.02 9537.76
857
1/8/99 9538.28 9647.96
9525.41 9643.32
940
1/11/99 9643.32 9643.32
9532.61 9619.89
816
:
:
Picture 12 DJI open, high, low, close and volume in 1999
= (Open(t)-Open(t-1))/Open(t-1)*100
= (High(t)-Open(t))/Open(t)*100
= (Low(t)-Open(t))/Open(t)*100
= (Close(t)-Close(t-1))/Close(t-1)*100
= (Volume(t)-Volume(t-1))/Volume(t-1)*100
= (Close(t+1)-Close(t))/Close(t)*100
The formulas can be entered easily into a spreadsheet table and will look as shown in
picture 13:
Date
Open
High
Low
Close
Volume
- 11/28/15 - 6:44 PM
Open
High
10 of 29 pages
Low
Close
Volume Close+1
755 -0.50274
0.147184 -0.99945
-1.005 27.10438
0.030932
883 -0.97163
1.381928
779 0.008384
1.676251
2.510742
986 1.422353
2.649371
-0.0196 1.381928
-11.778
0 2.510742 26.57253
-0.07554
857 2.433814
1.106759
940 -0.04045
-0.24297
816 1.101247
-1.50948
794 -0.25365
-1.32057
9213.1 9349.56
935 -1.53365
-2.44536
798 -1.28577
2.407868
921 -2.37872
2.360537
0.157057
0 2.407868 15.41353
This is usually done automatically, but we should take the time to examine normalization
parameters now.
Select PATTERNOPTIONS. For our current example you see the options as shown in
Picture 14.
Input1 for example has possible values between 2.378722 and 2.846741.
Suppose you have to normalize the value I1=0.5. You would calculate:
N(0.5) = (0.5 (-2.378722)) / (2.846741- (2.378722))
= 0.55090276
- 11/28/15 - 6:44 PM
11 of 29 pages
Create a new network with the values (5,5,7,1). This network has the required 5
inputs and 1 output.
Select NET LEARN PATTERN SET.
Leave the default values except the repetition count, which we set to 3000.
Press the Ok button
The training pattern set will now be processed 3000 times. Finally the trained network
automatically reproduces the inputs of the pattern set.
The results can be examined in Picture 15. Have a look at the columns O1 and NET(O1).
As you remember, NET(O1) is the output generated by the Neural Network, O1 is the
output we would like to get.
The values describe the percentage drop or gain between two days close values.
Our network at least has learned some of the patterns. Especially if our network makes a
significant statement (lets say it predicts a gain or drop of 0.6% or more) it is usually
right with the direction the DJI moves.
- 11/28/15 - 6:44 PM
12 of 29 pages
Now lets test the same network with the 2nd half year data. The network has not been
trained with these. So they are completely unknown to the network.
Please load dow99ii.pat into Pythia. Note that the normalization options are the
same for dow99i.pat and dow99ii.pat.
- 11/28/15 - 6:44 PM
13 of 29 pages
Picture 16 Reproducing the 2nd half 1999 data generates poor results
Next step would be to modify the model, usually by adding input parameters like interest
rates, overseas market indices, currency ratio etc.
- 11/28/15 - 6:44 PM
14 of 29 pages
Evolutionary Optimizer
The Evolutionary Optimizer is a tool for generating Neural Networks. The only thing you
must provide is the training pattern set. Lets see how the Evolutionary Optimizer
generates a network for the XOR sample:
You can find further explanations of the options in the reference part of this manual.
- 11/28/15 - 6:44 PM
15 of 29 pages
- 11/28/15 - 6:44 PM
16 of 29 pages
Reference
The reference part of this manual will describe in detail the menu items and the settings
in the various dialog boxes.
The Main Window
Pythias main windows contains three areas:
The pattern and the network area can contain any number of pattern sets or networks.
Any operation a user selects will process the currently selected pattern set or network.
The log windows displays the last transactions.
FILE EXIT
This terminates Pythia.
PATTERN READ PATTERN SET
This menu item reads a previously saved pattern set into pythia. Pattern set files have the
extension .PAT
PATTERN IMPORT PATTERN
SET
This menu item imports a data file as a
pattern set into pythia. The data files
format is assumed to be ASCII.
After choosing a file name a dialog
box as shown in Picture 19 will pop
up. A preview window displays the
first lines of the file.
You can further specify a field
delimiter, the number of fields per
record and the number of outputs.
Picture 19 Import pattern file dialog
- 11/28/15 - 6:44 PM
17 of 29 pages
Pythia tries to determine the field delimiter and the field per record value automatically.
Usually you wont have to change these.
The number of outputs field default to 1. You must change this if your data contain more
than one output.
Finally press the Ok button. Your new pattern set will be display on the left side of
Pythias main windows.
Note: During import some values will set automatically. These settings are the
Normalization parameters and the Display format.
Normalization:
The High of each input or output is set to the maximum value of the referred column.
The Low of each input or output is set to the minimum value of the referred column.
Display format:
The display for each column is set to (9,6), meaning the values will be displayed by a 9
character string with 6 characters after the decimal point.
PATTERN SAVE PATTERN SET
This menu item allows you to save the currently selected pattern set. Any special settings
like Normalization and Display format parameters are stored along with the pattern set.
PATTERN CLOSE PATTERN SET
This menu item closes the currently selected pattern set. The user will be prompted to
save this pattern set if it was modified.
- 11/28/15 - 6:44 PM
18 of 29 pages
PATTERN OPTIONS
This menu item allows you to change
certain settings for the pattern set.
Normalization:
A Neural Network expects any input and
output value to be between 0 and 1.
Therefore the pattern sets must be
normalized before being processed by
the network.
The normalization is calculated:
N(i) = (i - low) /
(high - low)
i is the input (or output value)
low is the minimum possible value
high is the maximum possible
value
The initial parameters are calculated when the pattern set was first created, either by
importing or by pasting. They are set to the lowest and highest value found in a column.
The low..high range should span any possible value. However, if your data set contain
any runaways you should either exclude these from you data or ignore them by
manually adjusting the normalization parameters.
You can change values in the option window by simply entering the new value into the
cell.
Alternatively, you can make use of the following operations:
Push this button to specify a new low value for all columns.
Push this button to specify a new high value for all columns.
Restore the default values (new calculation as if the pattern set was just created).
Discard changes.
Note: If you train a network with a certain pattern set you must choose the same
normalization parameters for another pattern set you are going to reproduce with this
network.
The display format parameters only specifies how the number are displayed in the table.
- 11/28/15 - 6:44 PM
19 of 29 pages
Display format:
The display format parameters specify how the numbers are displayed in the table.
By default the display for each column is set to (9,6), meaning the values will be
displayed by a 9 character string with 6 characters after the decimal point.
Use the following operations to change the look of the numbers:
Push this button to specify a new width for all columns.
Push this button to specify a new decimal value for all columns.
Restore the default values (9,6).
Discard changes.
PATTERN TOGGLE VIEW
Select this command to toggle between the original and the normalized form of the
pattern set.
You recognize the currently select view on the tab of the pattern set. The notation
N(xxx.pat) means normalized, xxx.pat indicates native (original).
- 11/28/15 - 6:44 PM
20 of 29 pages
Finally press the Ok button. The new created Neural Net is now displayed in the network
area of Pythias main window.
Picture 22 shows how this will look like.
- 11/28/15 - 6:44 PM
21 of 29 pages
- 11/28/15 - 6:44 PM
22 of 29 pages
Two parent networks will be chosen out of the old generation. The selection
algorithm will choose networks with a high fitness by a higher probability.
Two children networks will be created from the two parent networks.
With the probability of 0.2 the two children networks will be crossed over. This
means they will swap level with each other.
Example:
Child 1: (2,2,1)
(2,2 1)
Child 2: (2,6,6,1)
(2,6 6,1)
st
Compose the 1 part of child 1 with the 2nd part of child 2 to (2,2,6,1)
Compose the 1st part of child 2 with the 2nd part of child 1 to (2,6,1)
The children have been crossed over to (2,2,6,1) and (2,6,1).
The children now will be mutated with a probability of 0.04. Mutation means
insertion or deletion of a level, insertion or deletion of a neuron into a level or
change of weights.
The two parent network will now be checked if they belong to the 10 fittest
of the old generation. If they do they will be mutated and rolled over into the new
generation.
The selection continues until the new generation has 50 members too. After completion
the new generation will be evaluated.
The Evolutionary Optimizer is considered ready as soon as it found a network with a
fitness of 100.
Otherwise it continues for 1000 generations, what might take hours or days to compute.
You always can stop the process if you do not see any progress.
- 11/28/15 - 6:44 PM
23 of 29 pages
Options
There are lots of options you can finetune the optimizers work with.
1st ancestor Neural Net:
Specify a template network the first
generation is created from or allow to
generate a new random one with
create new.
Pattern set to learn:
Specify the pattern set you want to
generate a network for. This pattern set
must be loaded previously.
Check the option Mix pattern
randomly if you want to overcome a
given but unwanted sort order in the
pattern set. Note that a pattern sets
sort order influences the training phase
of the network.
Goals to achieve:
Here you can specify what the network should be optimized for. There are three goals
possible:
Tag or untag the checkboxes on the left side to determine if the certain goal shall play a
role at all.
If a goal is tagged specify the value you want to push the network below.
Specify the contribution a goal will make to the overall fitness.
The example in Picture 23 does not care about the medium deviation, but wants the max.
deviation to be below 0.25 and the network size below or equal 3. Both checked goals
will contribute 50% to the overall fitness of an evolutionary created network (1:1 =
50:50). If you would want the network size to have an importance of only 20% you
- 11/28/15 - 6:44 PM
24 of 29 pages
would have to enter the value 4 and 1 into the contribution fields for max. deviation and
size.
Evolutionary algorithms settings:
Different options influence the optimization process
Cross over rate: probability for a child network to be crossed over with another
child network
Modify fittest: if checked, the rolled over networks are modified with the given
mutation rate.
Pressing the Ok button starts the evolutionary process. You can watch the progress in the
progress window shown in Picture 24
During optimization you always can stop the process by pressing the Stop button.
The colored circle right of the checkbox show you the quality of a network. Red means
no goal achieved at all, yellow means some goals achieved and green means all goals
achieved. If there is any green network the optimization terminates.
- 11/28/15 - 6:44 PM
25 of 29 pages
When the optimization stops (by either finding a network with a fitness of 100 or
stopping manually) you can choose one or more network to be move into the network
area of Pythias main window.
The moved networks are ready for use.
NET REPRO PATTERN SET
This menu item causes the currently selected network to reproduce the currently selected
pattern set. The net output columns and the deviation column will be refreshed.
Note: You can only choose this command if the currently selected network is compatible
to the currently selected pattern set. Compatibility means same number of inputs and
same number of outputs.
- 11/28/15 - 6:44 PM
26 of 29 pages
Check this box to set the networks weights to initial random values. This might be
necessary because sometimes the given weight values do not lead to a suitable network
even if this is possible.
Train until:
Declare the cancel criteria of the learn plan here. You can connect the criteria with each
other by the AND or the OR operator.
The criteria for exiting the learn plan are:
Repetition
Medium deviation ( deviation)
Max. deviation within the pattern set (*deviation)
Time passed
- 11/28/15 - 6:44 PM
27 of 29 pages
Tag or untag the checkboxes on the left side to determine if the certain criterion shall play
a role at all.
In the example in Picture 25 the learn plan will stop as soon as
either the repetition count reaches 1000
or the max deviation is below 0.25
or 300 seconds have passed.
Learn rate:
The learn rate specifies how fast an error is propagated backwards. A large value
accelerates the learning, but might cause the network to overshoot the mark. Choose a
value between 0.1 and 0.5.
Tag Automatically adjust if you want Pythia to adjust the learn rate during the training
automatically. (Note: this feature is not implemented yet).
Finally:
Tag Reproduce pattern set if you want to get the pattern set reproduced after the training.
This is equivalent with the command NET REPRO PATTERN SET.
Check show results in native form to get the pattern set shown in their original form
instead of the normalized form. This is equivalent with the command PATTERN
TOGGLE VIEW.
NET REPRODUCE SINGLE
This menu item causes the currently
selected network to reproduce a
single pattern.
Manually enter the inputs, delimited
by a , .
The number of data you need to
enter equals the number of inputs of
the network.
Furthermore, you need to check if
the data entered will be interpreted
normalized or original.
- 11/28/15 - 6:44 PM
28 of 29 pages
- 11/28/15 - 6:44 PM
29 of 29 pages