QnetTool 2000

Sample Excel Macro

Automatic integration of Qnet models can be accomplished by any Windows application that supports a few basic tasks. All spreadsheet and database applications come with macro and programming languages that are well suited for integration with QnetTool. The basic tasks are as follows:

  1. Copy a set of inputs to the clipboard.
  2. Execute QnetTool in automatic mode.
  3. Paste (obtain) the recall answers from the clipboard.

That's it. Additional automation or increased user interaction can add additional complexities. For example, the Excel macro uses a dialog to interact with the user to determine the location of the inputs. Also, a formatting statement for the recall answers automates how the results are viewed.

The sample macro is available in OCR.XLS. The data in this spreadsheet is the training data used by the OCR model. The spreadsheet contains a data sheet and a macro sheet. A button on the data sheet has been assigned to the macro (via Excel's button tool).

The macro language used is Excel’s macro command set (fully supported under all current versions; use of Excel's Visual Basic command set is also an option). While our intent is not to teach the Excel programming languages, we will cover the macro commands used in this example.

The following represents the macro in OCR.XLS:

qnettool
=INPUT("Select Row",2,"Data Range Selection",,,)
="!A"&A2&"..BL"&A2
=SELECT(TEXTREF(A3,TRUE))
=COPY()
=EXEC("c:\qnetv2k\qnettool.exe c:\qnet97\mynn.net RUN",2)
="!BN"&A2
=SELECT(TEXTREF(A7,TRUE))
=PASTE()
=FORMAT.NUMBER("0.0000")
=RETURN()

The lines are summarized as follows:

qnettool - This is the identifying Excel macro name.

=INPUT - This prompts the user for the row containing the Neural Network Inputs.

=“!A”.... - This builds the selection address string. If we input row 10 above, the resulting address here would be !A10..Z10. Our fictitious model in this example would be using 26 inputs (columns A thru Z). The ! indicates this address reference the current worksheet. That means that when the macro is invoked (through buttons, hotkeys, etc.) the neural network data should be on our active sheet.

=SELECT - This selects the address built above. The TEXTREF statement turns our address string into an actual Excel address. The TRUE argument means we are using the default cell addressing scheme.

=COPY - This copies the selected text to the clipboard.

=EXEC - This runs QnetTool in automatic mode. We supply the full path to QnetTool along with two arguments. The argument is the neural network (with path) we wish to use the second argument tells QnetTool to RUN in auto mode and automatically generate results.

=“!AB”.... - This builds the address where we wish the answers to go. In this case, we place the answers on the same row as the inputs and in the 28th column.

=SELECT - Makes current the above address.

=PASTE - Pastes QnetTool’s result into the spreadsheet at the selected location.

=FORMAT - Formats the number using the template.

=RETURN - Terminates the macro.

Excel is a trademark of Microsoft Corp.