Python Forecaster (Python Scripting)
Synopsis
This operator generates a Python Forecast model that is compatible with Altair AI Studio's Apply Forecast Operator.Description
The Python Forecaster operator allows you to create custom forecast models using Python scripts within Altair AI Studio. Depending on the operator's configuration, you can edit the Python script to define the model's behavior according to your specific needs.
If the operator is editable, the parameter panel includes buttons at the top of the parameter list that allow you to:
- **Edit the Operator Declaration**: Customize capabilities, parameter types, and configurable input and output ports.
- **Edit the Python Script**: Modify the script that trains and applies your forecast model.
- **Save as Template**: Save your configuration for future use.
You can define user-configurable parameters to make your operator more flexible. To create a new parameter, extend the editable JSON parameters array by adding a new JSON object like the following: { "name": "my_new_parameter", "description": "This is a description what the parameter can be used for.", "type": "integer", "optional": false, "value": 100 }
Similarly, you can define user-configurable input ports. To create a new input port, extend the editable JSON inputs array by adding 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)
You can also define user-configurable output ports. To create a new output port, extend the editable JSON outputs array by adding a new JSON object: { "name": "my_new_output_port", "type": "table" }
The Python script requires two functions: rm_train and rm_apply.
The rm_train function is responsible for training the model. It should return an object that contains the trained model and any other data needed by the rm_apply function. If you have defined user-configurable output ports (e.g., to output performance metrics), you should return them along with the model object. For instance: return model_object, pd.DataFrame({"performance": [performance_metric]})
If you have multiple output ports, return additional DataFrames for each: return model_object, dataframe_output1, dataframe_output2
Note that the parameters variable in the rm_train function includes the names of the time series attribute (series_name) and the index (index_name) by default.
The rm_apply function is called by the Apply Forecast operator to perform forecasting. The model argument contains the Python object returned by the rm_train function. This function should return the forecasted values as a pandas DataFrame.
Please note that the model generated by this operator wraps the Python model returned by your Python script. Both training and applying the model require a compatible Python environment.
The Apply Forecast operator uses the trained forecast model to generate forecasts for the time series it was trained on.
Input
- training set (Data table)
The input data used to train the Python Forecast model.
Output
- model (Model)
The wrapped Python Forecast model is delivered from this output port.
- example set (Data table)
The input example set is passed through to this output port unchanged.
Parameters
- operator If enabled, this parameter allows to edit the operator declaration (such as capabilities and parameter types) and the Python script used to train and apply the Python model.
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.