Macros & Scripts

Macros & Scripts
 
Macros.
 
Macros are recorded while EasyNN-plus is being used.  Recording is started with Record on the Macro menu or Ctrl + F2.  Recording is stopped using Stop recording on the Macro menu or Ctrl + F3. EasyNN-plus macros are text files with the .ens extension.  Functions are fully recorded when possible but some are only partially recorded or they are nested within other functions.  The right click, grid pre-processing functions are not recorded.
 
Script Commands can be added to macros using Commands on the macro menu.  Recording can be continued after adding script commands or recording can be stopped and the commands can be played immediately.  Multiple script commands are separated with a ; character.  For example, if the line f; stl; fps(0,0,1,100) is entered it will be split into three separate script commands in the macro.  If the macro is then played back the commands will cause the currently open network to forget learning, start learning and then stop learning after 100 cycles.  Alternatively recording can be stopped and the commands played by adding three colon characters.  The example would become f; stl; fps(0,0,1,100); ::: .
 
Whole scripts can be added to macros using Add Expanded Script on the Macro menu.  The selected script file will be expanded into its original format and then each command will be added to the macro.  Recording can be continued after adding an expanded script file.
 
A script file can be added at the end of a macro using Add Script File on the macro menu.  This will put a RunScriptFile(script file); command into the macro.  When the macro is played back it will play the recorded functions and script commands.  It will then run the script file and terminate the macro.
 
Playback is started using Play on the Macro menu, Ctrl + F4 or using Run Script File on the File menu.  Macro files can also be passed to EasyNN-plus as a parameter in the same way as script files.
 
A macro called specscr.ens is included in the Samples folder that creates a network similar to the Species.tvq sample.
 
Scripts.
 
EasyNN-plus scripts are text files with .ens or .txt extensions and can be edited with any text editor.  Script files can be loaded and run from within EasyNN-plus using Run Script File on the File menu.  They can also be passed to EasyNN-plus as a parameter.
 
Scripts can contain commands to import the data, build the neural network, control learning, validating and querying.
 
Warning:     Script commands call low level functions.  The command parameters are validated but some error checking has to be disabled so that the scripts will run.  All scripts should be designed and tested very carefully.  Script commands that will overwrite existing files should only be used when backup files are available.
 
Script files based on the currently loaded network can be produced using Generate Script File on the File menu.  The generated files will contain commands to create the grid columns and set the network controls.  Commands to create the grid rows, import the data and build the neural network can then be added.
 
Scripts can be tested by stepping through them one line at a time.  Start the script with an ess command to enable single step mode.
 
The pause command can be used to temporarily stop and exit from a script.  When the script is restarted it will run from the line after the pause.
 
The commands and error messages that are produced while running the script can be directed to a log file by including the lsc command in the script.  The script will stop if the lsc command fails to open the log file.
 
The name of a script file can be passed as an EasyNN-plus parameter in the command line.
 
This test line shows how to call EasyNN-plus from Start > Run.
 
"C:\Program Files\EasyNN-plus\EasyNN.exe"  "C:\Program Files\EasyNN-plus\Samples\ascript.txt"
 
The script imports atest.txt and uses it to create a network.  The files ascript.txt and atest.txt are included in the Samples folder.
 
 
Macro and Script Commands.
 
Comments: Lines starting with any non alpha character can be used for comments.
 
Parameters:
 
String parameters are checked to be valid strings.
Integer and double parameters are checked to be within the valid range.
Bit parameters are checked to be 0 (false) or above 0 (true).
Macro parameters are produced while recording.
 
Macro functions can be included in Scripts but they must be tested very carefully.  Script command names are shown in black, macro function names are shown in red.  When a macro function has exactly the same parameters as a script command it is listed below the command.  All macro functions are case sensitive.  Script commands in full or as short names can be in any case.
 
 
AddCol                    Adds a column
 
          bit          Ask (ignored)
          bit          Output
          bit          New column
 
 
AddRow                    Adds a row    
   
          bit          Ask (ignored)
          int          Type
          bit          Head
          bit          Modified
 
 
autosave                    Set AutoSave    
as
 
          string      File base name
          int          Cycles per save
          bit          Save if lower error
          bit          Save if validating results improve
 
 
autosaveassociationsfile
asas
AutoSaveAssociationsFile
 
          string     File name
 
 
autosaveclustersfile
ascl
AutoSaveClustersFile
 
          string     File name
 
 
backto                    Go back to label
bt                   
 
          string      Label
          int          Repeats
 
    Warning:     Only one backto or bt command is allowed in a script.
 
 
createcolumns               Creates columns    
cc
 
          int          Number of columns
 
 
ChangeNetwork               Increase nodes    
 
          int          Number of nodes to add to hidden layer
          int          Hidden layer number 1, 2 or 3
 
 
ChangeRows                    Change rows
 
          int          Change to; 0 Training, 1 Validating, 2 Querying, 3 Excluded
          int          First row to change
          int          Number of rows to change
 
clipcolumn                    Clip column
clc
 
          int          Column number
          bit          Cut clipped column
 
 
cliprow                    Clip row
clr
 
          int          Row number
          bit          Cut clipped row
 
 
cloningoff               Cloning off
cof
 
 
cloningon               Cloning on
con
 
 
Close                         Closes the application          
 
 
CloseDocument               Closes the document
 
columntypeandmode           Set columns type and mode
ctm
SetColumnsTypeAndMode         
 
          int          First column to set
          int          Number of columns to set
          int          Type; 0 Input, 1 Output, 2 Exclude, 3 Serial
          int          Mode; 0 Real, 1 Integer, 2 Bool, 3 Text, 4 Image
 
 
CompleteEditGrid               Complete edit grid cell    
 
          int          Column
          int          Row
          double     Value
          string      String value
          int          Mode
          int          Type
 
 
createnetwork               Creates a network from the Grid
cn
 
          int          Nodes in hidden layer 1
          int          Nodes in hidden layer 2
          int          Nodes in hidden layer 3
          bit          Optimize hidden layer 1
          bit          Optimize hidden layer 2
          bit          Optimize hidden layer 3
 
 
createrows                    Creates rows
cr
 
          int          Number of rows
 
 
DeleteCol                    Deletes a column
 
          int          Column
          bit          Ask (ignored)
 
 
DeleteRow                    Deletes a row    
 
          int          Row
          bit          Ask (ignored)
          bit          Modified
          bit          Duplicate
          bit          Scale
 
 
disableresults               Disable results columns
dr
 
          int          First column
          int          Number of columns
 
 
disablesinglestep               Disable single step
dss
 
 
EditCopy                    Copy selection to clipboard
 
          int          Column
          int          Row
 
 
EditCut                    Cut selection to clipboard    
 
          int          Column
          int          Row
 
 
EditGrid                    Edit grid cell
 
          int          Column
          int          Row
          int          Type
          string      Column name
          string      Row name
 
 
EditPaste                    Paste from clipboard    
 
          bit          Column clipped
          int          Column
          bit          Row clipped
          int          Row
 
 
endofscript                    End of script
eos
 
 
enableresults               Enable results columns
er
 
          int          First column
          int          Number of columns
 
 
enablesinglestep               Enable single step
ess
 
 
exit                         Exit    
x
 
          bit          Prompt to save
 
 
extendrange               Extend the training range                             
exr
ExtendRange              
 
          int          Column
          double     Value
 
 
forget                         Forget
f
 
          bit          Restart random number sequence
 
 
ForgetLearning               Forget    
 
          bit          Ask
          bit          Restart
          bit          Reset errors
          bit          ReSeed
          double     Range
 
 
fixedperiodstops               Set fixed period stops
fps
SetFixedStops
 
          bit          Stop after seconds
          double     Seconds
          bit          Stop after cycles
          int          Cycles
 
 
importbinaryfile               Import binary file
ibf
SetImportBinaryFile              
 
          string      File name
          int          Initial bytes to skip
          int          Bytes per column
          int          Columns per row
 
 
ignoreerrors                    Ignore errors
ie
 
          bit          Cancel
 
importimagefiles               Import bitmap image files
iif
ImportImageFiles
 
          string     Path to folder
          string     File name
          int          First column
          int          First row
          bit          Import all bitmaps in folder
          string     Prefix              
 
 
importtextfile               Import text file                             
itf
ImportTextFile
 
          string      File to import
          bit          Use first line as column names
          bit          Use first word(s) on line for row names
          bit          Tab delimiters
          bit          Comma delimiters
          bit          Space delimiters
          bit          Stop (period) delimiters
          bit          Colon delimiters
          bit          Semicolon delimiters
          bit          Initialize Grid for text and image modes
 
 
importxlsfile                    Import XLS file
ixf
ImportXLSFile              
 
          string      File to import
          string      Sheet name
          bit          Set column names from first row
          bit          Set row names from first column
 
 
learningcontrols               Set the learning controls
lc
SetLearningControls              
 
          double     Learning rate
          double     Momentum
          bit          Decay learning rate
          bit          Decay momentum
          bit          Optimize learning rate
          bit          Optimize momentum
 
 
logscriptcommands               Log all script commands including failures.
lsc              
 
          string      Log File name
 
 
networkreconfiguration          Set network reconfiguration controls
nr
SetReconfigurationControls         
 
          bit          Allow manual reconfiguration
          bit          Grow hidden layer 1
          bit          Grow hidden layer 2
          bit          Grow hidden layer 3
 
 
NewNetwork                    New network from current grid
 
          int          Inputs (ignored)
          int          Nodes in hidden layer 1
          int          Outputs (ignored)
          bit          Reset (ignored)
 
newweight                    New weight connection from node to node
nw
 
          int          From node
          int          To node
 
deleteweight               Delete weight connection from node to node
dw
 
          int          From node
          int          To node
 
open                         Open a network file
o              
 
          string      File to open
 
 
order                         Set the sort order
or
Order              
 
          bit          0 Descending, 1 Ascending
 
 
paste                         Paste clip
p
 
 
pause                         Pause and leave script
ps
 
          bit          0 No prompt, 1 Prompt to continue
 
 
query                         Query from file
q
SetFileQuery              
 
          string      Query file
          string      Results file
          bit          No row names in query file
          bit          No column names in query file
          bit          Tab delimiters
          bit          Comma delimiters
          bit          Space delimiters
          bit          Stop (period) delimiters
          bit          Colon delimiters
          bit          Semicolon delimiters
          bit          Show results file
          bit          Comma delimiters in results file
 
 
refresh                    Refresh display when paused
rf
 
 
reset                         Reset AutoSave
r
 
          bit          Saved error
          bit          Saved validating
 
 
readbinaryfile               Read binary file
rbf
 
          string      File name
          int          Bytes to skip
          int          Bytes to read
          int          Repeats
 
 
rowtype                    Set row types    
rt
 
          int          First row to set
          int          Number of rows to set
          int          Type; 0 Training, 1 Validating, 2 Querying, 3 Exclude
 
 
RunScriptFile                    Run a script file    
 
          string      Script file name
          bit          Edit (ignored)
 
 
save                         Save
s
          string      File name
          bit          Do not change Window title    
 
 
SetAutoSave               Set auto save    
 
          string      File name
          int          Cycles per save
          bit          Error decrease
          bit          Validating increase
          bit          Do not ask
          bit          Details on exit
 
 
setbinarysizes               Set binary sizes    
sbs
 
          int          Bytes per Column
          int          Columns per row
 
 
setjoglevel                    Sets the jog level
sj
SetJogLevel
 
          int          0 None, 1 Low, 2 Medium, 3 High
 
   
setnoisel               Sets the noise level
sn
SetNoise
 
          int          Noise level 1 to 10
          int          On/Off  1/0
 
 
setview                    Sets the view    
sv
SetView         
 
          int          View; 0 Blank, 1 Grid, 2 Associations, 3 Learning graph, 4 Network,
                        5 Errors,  6 Importance, 7 Sensitivity, 8 Predictions, 9 Column graph
          bit          Sort; 0 Ascending, 1 Descending
 
    Warning:     Forcing inappropriate views using SetView, setview or sv in a macro may cause a crash.
 
    Warning:     When running from the command line, a script or macro that includes any SetView,
              setview or sv may cause a crash if the script or macro fails before it reaches the end. 
              This is because the view does not exist during command line runs. To avoid the
              problem the change of view is delayed until the script has ended.
 
 
showwindow                    Shows the Window    
sw
          int          0 Hide, 1 Normal, 2 Minimize, 3 Maximize, 4 Show but no activate, 5 Show and activate
 
 
    Warning:     If a script or macro includes showwindow(0) or sw(0) EasyNN-plus will run hidden. 
              It will remain hidden until another showwindow is executed with a parameter greater
              than zero. Scripts and macros that do not make EasyNN-plus visible may leave the
              process hidden and running. If the script or macro ends or fails while EasyNN-plus is
              hidden an attempt is made to become visible. Do not assume that this will always be
              successful. Some script failures cannot be detected by an hidden process.
              Windows Task Manager can be used to kill hidden processes.
 
 
specialfiles                    Special files
sf
SpecialFiles
 
          bit          Save weights  biases
          bit          Save all the grid
          bit          Save the graph points
          bit          Save the weights  connections
          string      Terminal file name for immediate save
          bit          Save as comma delimited files (csv)
          bit          Save example errors
          bit          Save sensitivities
          bit          Save importances
 
 
StartAssociating               Start associating
 
          bit          Skip excluded columns
          bit          Clear existing associations
 
 
StartForecasting               Start forecasting    
 
          int          Period
          int          Steps    
 
 
startlearning               Start learning
stl
StartLearning                   
 
    Warning:     The time taken by a process between starting and stopping is recorded
              for use as the maximum wait time in the WaitForStop function. When the
              macro is played back the recorded maximum wait time is increased by a
              generous margin to allow for timing variations. This margin is normally
              sufficient for quite wide variations but on much slower systems or when the
              system is heavily loaded some problems may occur.
 
 
stoplearning                    Stop learning or associating
spl
Stop         
 
 
targeterrorstops               Set the target error stops
tes
SetLearningStops              
 
          bit          0/1 Average error / all errors
          double     Target error
 
 
validatingcontrols               Set the validating controls
vc
SetValidatingControls              
 
          int          Training cycles before first validating cycle
          int          Training cycles per validating cycle
          int          Percentage of training examples to change to validating
 
 
validatingstops                    Set the validating stops
vs
SetValidatingStops              
 
          double     Percentage validating that must be in range or correct
          double     +/- Range percentage
          bit          0/1 Test in range / correct after rounding
          bit          Stop if validating examples decreases
          bit          Stop if target score reached
          int          Target score
          bit          Inhibit range and correct validating
          bit          Stop if average validating error is increasing    
 
 
wait                              Wait
w    
 
          int          Milliseconds to wait
 
 
 
waitforstop                         Waits for stop
wfs
WaitForStop              
 
          int          Maximum milliseconds to wait
          int          Wait for; 14 Learning, 16 Associating, 23 Forecasting
 
 
1

Notepad

1. NotepadA simple macro opened in Notepad
 
2

Functions

2. FunctionsA series of recorded functions that open a file, creates a network, starts learning, waits for it to finish and then saves the trained network. 
 

Created with help of DrExplain