Last updated: Jan 18, 2024
You can use a flow to train a neural network model when executed. Normally, to test the model, you might run the modeling node to add the model to the flow, make the appropriate connections, and run an Analysis node.
Using an SPSS Modeler script, you can automate the process of testing the model nugget after you create it. Following is an example:
stream = modeler.script.stream()
neuralnetnode = stream.findByType("neuralnetwork", None)
results = []
neuralnetnode.run(results)
appliernode = stream.createModelApplierAt(results[0], "Drug", 594, 187)
analysisnode = stream.createAt("analysis", "Drug", 688, 187)
typenode = stream.findByType("type", None)
stream.linkBetween(appliernode, typenode, analysisnode)
analysisnode.run([])
The following bullets describe each line in this script example.
- The first line defines a variable that points to the current flow
- In line 2, the script finds the Neural Net builder node
- In line 3, the script creates a list where the execution results can be stored
- In line 4, the Neural Net model nugget is created. This is stored in the list defined on line 3.
- In line 5, a model apply node is created for the model nugget and placed on the flow canvas
- In line 6, an analysis node called
Drug
is created - In line 7, the script finds the Type node
- In line 8, the script connects the model apply node created in line 5 between the Type node and the Analysis node
- Finally, the Analysis node runs to produce the Analysis report
It's possible to use a script to build and run a flow from scratch, starting with a blank canvas. To learn more about the scripting language in general, see Scripting overview.