I would like to extract the parameters of ARIMA model (AR, Differencing, MA) from the executed time series nugget by scripting.
I tried to extract them via "PMML", but it was impossible because "PMML" is not supported for time series model such as ARIMA. Therefeore, I'm currently trying to do that using the following Python scripting by referring to a related post (https://www.ibm.com/developerworks/community/forums/html/topic?id=4136cd60-2510-4c1e-b735-462c0cedfb9f).
stream = modeler.script.stream() supernode = modeler.script.supernode() diagram = supernode.getChildDiagram() buildnode = diagram.findByType("applytimeseries", arima1) cm = buildnode.getContentModel("TSCXML") print cm.getXMLAsString()
This can run without errors, but nothing is printed on the screen, and I don't know how to export TSCXML data to a file or to extract the parameters from TSCXML data.
Could you tell me how to do that via TSCXML? In addition, instead of TSCXML, if there any other good ways to export the prameters, it would be really helpful if you could share them.
Thank you very much in advance.
It looks like the TSCXML has been deprecated as a format and what remains in the demo stream is an old model - if I replace the build node with a new one and delete the apply node (so a new one gets generated), the TSCXML is empty.
I'm not sure which parts of the model you need but you can get some information by exporting the model as text:
from modeler.api import FileFormat stream = modeler.script.stream() tr = modeler.script.session().getTaskRunner() applynode = stream.findByType("applytimeseries", None) tr.exportModelToFile(applynode, "C:/temp/tsmodel.txt", FileFormat.PLAIN_TEXT)
However, that doesn't appear to include all the information you need. Looking at the apply node's dialog, are there values there that you need?
The short answer is that I'm not sure why it's not working.
Start SPSS Modeler and open the broadband_create_models.str file from ModelerInstallation/Demos/streams. This stream includes a Time Series applier node. Try pasting the following script into the stream's 'Execution' tab:
stream = modeler.script.stream() applynode = stream.findByType("applytimeseries", None) cm = applynode.getContentModel("TSCXML") print cm.getXMLAsString()
If you run this and look at the Debug sub-tab, you should see the TSCXML appearing in it.
I've tried it in SPSS Modeler 17.0 and 17.1. Which Modeler version are you using?
looping script in python 2 Answers