Python Forecaster (Python Scripting)
Synopsis
This operator generates a Python Forecast model that is compatible with RapidMiner's Apply Forecast Operator.Description
The behavior of this operator is defined by a Python script that, depending on the operator configuration, can be edited by the user.
If the operator is editable, the parameter panel features a set of buttons at the top of the parameter list that allow to edit the declaration (e.g., capabilities and parameter types, configurable input and output ports) and the Python script, as well as to save the configuration as template.
It is possible to define user configurable parameters. To create a new parameter the editable JSON parameters array should be extended by a new JSON object. { "name": "my_new_parameter", "description": "This is a description what the parameter can be used for.", "type": "integer", "optional": false, "value": 100 }
It is possible to define user configurable input ports. To create a new input port the editable JSON inputs array should be extended by a new JSON object. { "name": "my_new_input_port", "type": "table" } The new input can be easily reached by adding an extra attribute to the rm_train method. For example: rm_train(index, series, new_input_data, parameters)
It is possible to define user configurable output ports. To create a new output port the editable JSON outputs array should be extended by a new JSON object. { "name": "my_new_output_port", "type": "table" }
There are two functions in the Python script. These are the rm_train and rm_apply functions.
The rm_train function is responsible for training a model. It should return an object which is passed to the rm_apply function. This object contains the trained model and everything else which is needed in the rm_apply function. If there are user configurable output ports, for example a performance output port to be able to see the performance of the training, it also has to be returned the following way: return object_pass_to_rm_apply, DataFrame({"performance": [performance]}) If there are more user configurable output ports: return object_pass_to_rm_apply, dataframe_output1, dataframe_output2 ...
It is important to note that the parameters variable in the rm_train function contains the name of the time series attribute (series_name) and the name of the index (index_name) by default.
The rm_apply function is called by the Apply Forecast operator. It is responsible for the forecasting. The argument model contains the Python object returned by the rm_train function. This function should return the forecasted values. (In DataFrame)
Please note that the model generated by this operator wraps the Python model returned by the Python script. Both training and applying the model requires a compatible Python environment.
The Apply Forecast operator receives a trained Forecast Model and creates the forecast for the time series it was trained on.
Input
- training set (Data Table)
The input data which is used to generate the Python Forecast model.
Output
- model (Model)
The wrapped Python Forecast model is delivered from this output port.
- example set (Data Table)
The example set that was given as input is passed without changing to the output through this port.
Parameters
- operator If enabled, this parameter allows to edit the operator declaration (e.g., capabilities and parameter types) and the Python script used to train and apply the Python model. Range: configurable
Tutorial Processes
Python Forecast Operator - fbprophet package
This example shows how to create a single Python Forecaster using the fbphorbet package.
Python Forecaster Operator - ARIMA forecast
This tutorial process shows how to create a Python Forecaster Operator with ARIMA forecasting.
Python Forecaster Operator - SARIMA forecast
This tutorial process shows how to create a Python Forecaster Operator with SARIMA forecasting.
Python Forecaster Operator - SARIMA forecast
This tutorial process shows how to create a Python Forecaster Operator with SARIMA forecasting but with a different Python package.
Python Forecaster Operator - multivariate forecast
This tutorial process shows how to create a multivariate forecast with Python Forecaster Operator.