CaDS is a good choice for regular processing of streams created with SPSS Modeler, but if you don't need that much fine-grained management or the scale isn't large, SPSS Modeler Batch is also a good choice. I will. SPSS Modeler Batch connects to SPSS Modeler Server and executes streams by executing from a command. GUIs like SPSS Modeler Client will not launch. Basically it runs all the terminal nodes placed in the stream. SQL pushback and cache set in the stream also work effectively. As an example of how to use it, if there is a process such as executing sales forecast of a certain business every day or updating the forecast model every week, create a stream to perform that process and batch command (clemb) of SPSS Modeler Batch. Can be achieved by executing at the specified time from another scheduler (CRON etc. for UNIX).
Command example
clemb -stream "/XXX/.../XXX.str" -execute -server -hostname XXX -username XXX -password XXX -Pmth=Jan
You can pass arguments to the stream with the -P option when running SPSS Modeler Batch. As described in the following manual, for example, if you write Month ='\ $ P-mth' in the condition extraction node and execute it with the argument -Pmth = Jan when executing in the modeler batch, mth = Jan is carried over to the stream. Month ='\ $ P-mth' becomes Month ='Jan', which allows you to extract only the data that corresponds to Month ='Jan'. It is also possible to extract data under different conditions such as Month ='Feb' by changing the character string following -Pmth = in batch execution.
"Use parameters in batch mode" (In the manual, the equation is ==, but it is equivalent to =.)
If you use this method and execute it by giving a branch name as an argument to one stream, you can also forecast sales and update the model for each branch.
As mentioned above, SPSS Modeler Batch will execute all terminal nodes in the specified stream, but if you want to execute only a specific terminal node, specify the order in which the terminal nodes are executed, or update the model. , Controlled by the accompanying Python script. The method shown in the manual link above was to incorporate the arguments into the CLEM expression set inside the node of the stream, but I would also like to introduce how to incorporate the arguments into the Python script that accompanies the stream. For example, if you want to pass the branch name with the option Branch, set it with -PBranch = as shown below.
Command entry example
clemb -stream ...(Omission)... -PBranch=GINZA
To include it in a Python script, use the getParameterValue () method of the session () or stream () instance. There is a difference that stream () is valid for the target stream and session () is valid for all open streams, but the parameters obtained by Modeler Batch are obtained from both session () and stream (). I can do it. For session () and stream (), write them in the Python script as shown in the following example.
session()in the case of
session = modeler.script.session()
Branch_Name = session.getParameters().getParameterValue('Branch')
stream()in the case of
stream = modeler.script.stream()
Branch_Name = stream.getParameterValue('Branch')
If you execute the batch with this, ‘GINZA’ will be assigned to the Branch_Name variable in the previous example. After that, you can handle it freely, such as assigning it to the CLEM expression of the node in the Python script. Variables are imported as character strings, so if you want to treat them as numbers, you need to perform type conversion such as int ().
There is also a description in the following manual about importing parameters into Python scripts. (It's a little confusing.)
Recommended Posts