SPSS Statistics

 View Only

Red Node Blog: Last Orders

By Archive User posted Wed May 20, 2015 09:27 PM

  

As this is my first blog, I suspect that the best place to start is at the end, and tell you about an option to change the order in which things will happen.


I left the SPSS Modeler development team in 2013, just as we were putting the final touches to Modeler 16. It was, by any standards, a big release, but one of the features stood out to me as being something that users (and developers) had been hoping for for a very long time.  This was the addition of Python (or more technically "jython") scripting to supersede the legacy scripting language which had helped Modeler through the first 20 years of its life.

Now Python is the kind of language no self-respecting data scientist would say a bad word against, but for normal human beings, especially those still getting to grips with learning Modeler, it can seem a huge learning curve to do some fairly simple tasks, and it's one such task I want to talk about here.


blog1

In essence, Modeler streams are computer programs. They are in many ways much nicer to work with than conventional languages/environments, however in one respect they are not clear. Imagine a simple stream which splits and ends in two different terminal nodes - here a table and graph.

In this example, I can select the table and run that, or I can run the graph. But what happens if I run the whole stream? Does the graph run first then the table, or does the table run first then the graph?  There is in fact no obvious visual indication of the order in which things will run, nor any obvious way of changing that order.  Now for the keenest reader you might already have guessed that Python scripting is a great way to control the order - but what if you are not so familiar with scripting and are in a hurry?

Well the good news is that, we recognized this might be an issue and took the opportunity to add in support for this in such a way that Modeler would help write the script for you, behind the scenes. So how should you go about it?


One of the most important parts of the Modeler interface is the stream properties dialog. In this dialog you see all the stream level properties and settings for the current stream.  It can be accessed in a number of ways (tool bar status bar etc), but the way I suggest for newer users is through the Tools menu on the main application menu bar.
i.e.  Tools > Stream Properties > Execution...

This brings up a tabbed dialog box open on the Execution tab. And you will notice the radio buttons - almost hidden - which let you choose execution mode.


(Users of earlier versions may have noticed that "Execution" tab in this dialog was in earlier versions of the software called "Scripting")


Option for looping / conditional execution

If you select the radio button for "Looping / Conditional Execution" the panel below changes to show a tabbed panel with two tabs, "Conditional" and "Looping".


Looking at the Conditional tab you will see a set of buttons to the right.


Conditional tab - with a button to edit condition

Clicking on this button brings up a small dialog from which you can pop up a list of all the terminal (executable) nodes. You then get to choose a condition.


Often we set condition to Always true

I am not sure why the Condition drop down defaults to "Stream Parameter" but most often you will change it to "Always True".
You do the same for each of your executable nodes and the you can then very simply control the order in which they execute, using the up and down arrows.


Now, as I mentioned earlier, behind the scenes Modeler is creating a Python script. If you want to see it - simply click on the Paste button in the bottom right hand corner...  And that's it!


OK so the intention behind this blog entry was to point you towards a feature which is perhaps a little hidden and to encourage you to explore the feature more fully. The purpose of the feature itself was in part to get you up and running with Python scripting. The conditional execution feature was one I designed at the end of my time with the SPSS Modeler development team, but was something which a colleague asked about today so I felt it was as good a place to start a blog as any.

Happy modeling






#python
#scripting
#SPSSModeler
#SPSSStatistics
0 comments
10 views

Permalink