Data to Neural Network

 
This procedure is a step by step guide to creating a neural network from a data file.
 
All you need to start is the Races.txt file.  You will find a copy in the samples folder.
Have a look at the contents of the file.  You will see that the column titles are on the first line and the other lines start with the line number in square brackets  We will use the titles for column names and the numbers for row names.  Some of the values in the race data are integers and some are boolean.
 
The file contains data from 370 horse races.  The aim is to create a neural network that can be trained and validated using the horse race data.
 
After the neural network has been trained and validated it can be used to help predict the winner of other races.
 
Press the New toolbar button or use the File > New menu command to produce a blank grid for a new neural network.
 
An empty Grid with a vertical line, a horizontal line and an underline marker will appear.
 
Now select File > Import...
 
The file selection dialog will appear.
 
Open the file Races.txt in the samples folder.
 
The first Import dialog will appear with the Tab delimiter already checked. 
 
Each line is numbered in Races.txt so that can be used as the row name.  Select "Use first word(s) on each line for row names".  Press OK.
 
The second Import dialog will appear.
 
Press the Set names button.
 
The first line and the column names will be set.
 
The third import dialog called Input/Output Columns will appear.  The settings in this dialog are based on the value being imported but they should be checked.  In particular the mode and type may not always be correct.
 
Column 0 will be ready to setup.  The column is called Runners and has a value of 11.  The column settings will be correct so press OK.
 
The next column will now be shown.  This column is Distance with a value of 7.  The settings are correct so press OK.
 
Column 3 is Handicap with a value of 0.  The mode will change to Bool.  Press OK.
 
Column 4 is Class and is another integer.  The mode will change back to Integer.  Press OK.
 
Column 5 and 6 are boolean so the mode will be set to Bool.  Press OK for both columns.
 
The last column is Win and is also a boolean so the mode will be correctly set.  The type is not correct and needs to be changed to Output.  Then press OK.
 
The data will be imported and the grid columns will be set to the correct mode and type.
 
The Grid is now complete.
 
To create the neural network press the Grow new network toolbar button or use the Action > New Network menu command.
 
This will open the New Network dialog.
Check Grow layer number 1 and press OK.
If you get a "Generating new network will reset learning." warning message answer Yes.
The neural network will be produced from the data you imported into the Grid. 
 
Answer Yes to the message "Do you want to set the controls?".
 
This will open the Controls dialog.
Check Optimize for both Learning Rate and Momentum.
We need to change 100 of the training rows to validating so enter 100 in Select examples at random
There is no point in training the neural network for more than 1000 cycles so check Stop on cycle and enter 1000.
Press OK.  Answer Yes if you get the "Optimizing controls will reset learning." warning message.
 
The controls will be set and the neural network will be ready to learn.
 
A summary of the control settings and what is going to happen next will appear.
Answer Yes to the message "Do you want filename to start learning?".  The filename will probably still be called untitled.tvq, there is no need to change it unless the file is saved.
 
The AutoSave dialog will open.  Nothing needs to be done so just press OK.
 
Learning and validating will run for 1000 cycles.  Use View > Information to see the results.  The line Validating results: ... is all that matters.  If everything has worked as expected the neural network will have correctly predicted the results of at least 64% of the races.
 
That is the end of this exercise.
 
If you want to try using the query facilities to input details of races and horses you can enter the queries directly into the Grid or use the Query dialog.
 
If you are using the full version you will be able to use a File Query to produce a results file for a whole days racing.  Races that indicate no winners or multiple winners should be ignored.
 
 
 

Created with help of DrExplain