| |
- ArimaForecast(data=None, data_filter_expr=None, forecast_periods=None, output_fmt_index_style='NUMERICAL_SEQUENCE', **generic_arguments)
- DESCRIPTION:
The ArimaForecast() function is used to forecast a user-defined number of periods based on
models fitted from the ArimaEstimate() function.
The following procedure is an example of how to use ArimaForecast:
1. Run the ArimaEstimate() function to get the coefficients for the ARIMA model.
2. Run the ArimaValidate() function to validate the "goodness of fit" of the ARIMA model,
when "fit_percentage" is not 100 in ArimaEstimate.
3. Run the ArimaForecast() function with input from step 1 or step 2 to
forecast the future periods beyond the last observed period.
PARAMETERS:
data:
Required Argument.
Specifies the TDAnalyticResult object over the output
generated by either ArimaEstimate() or ArimaValidate() function.
Types: TDAnalyticResult
data_filter_expr:
Optional Argument.
Specifies the filter expression for "data".
Types: ColumnExpression
forecast_periods:
Required Argument.
Specifies the number of periods to forecast ahead.
Types: int
output_fmt_index_style:
Optional Argument.
Specifies the index style of the output format.
Permitted Values: NUMERICAL_SEQUENCE, FLOW_THROUGH
Default Value: NUMERICAL_SEQUENCE
Types: str
**generic_arguments:
Specifies the generic keyword arguments of UAF functions.
Below are the generic keyword arguments:
persist:
Optional Argument.
Specifies whether to persist the results of the
function in a table or not. When set to True,
results are persisted in a table; otherwise,
results are garbage collected at the end of the
session.
Note that, when UAF function is executed, an
analytic result table (ART) is created.
Default Value: False
Types: bool
volatile:
Optional Argument.
Specifies whether to put the results of the
function in a volatile ART or not. When set to
True, results are stored in a volatile ART,
otherwise not.
Default Value: False
Types: bool
output_table_name:
Optional Argument.
Specifies the name of the table to store results.
If not specified, a unique table name is internally
generated.
Types: str
output_db_name:
Optional Argument.
Specifies the name of the database to create output
table into. If not specified, table is created into
database specified by the user at the time of context
creation or configuration parameter. Argument is ignored,
if "output_table_name" is not specified.
Types: str
RETURNS:
Instance of ArimaForecast.
Output teradataml DataFrames can be accessed using attribute
references, such as ArimaForecast_obj.<attribute_name>.
Output teradataml DataFrame attribute name is:
1. result
RAISES:
TeradataMlException, TypeError, ValueError
EXAMPLES:
# Notes:
# 1. Get the connection to Vantage to execute the function.
# 2. One must import the required functions mentioned in
# the example from teradataml.
# 3. Function will raise error if not supported on the Vantage
# user is connected to.
# Check the list of available UAF analytic functions.
display_analytic_functions(type="UAF")
# Load the example data.
load_example_data("uaf", ["timeseriesdatasetsd4"])
# Create teradataml DataFrame object.
data = DataFrame.from_table("timeseriesdatasetsd4")
# Execute ArimaEstimate() function to estimate the coefficients
# and statistical ratings corresponding to an ARIMA model.
# Create teradataml TDSeries object.
data_series_df = TDSeries(data=data,
id="dataset_id",
row_index="seqno",
row_index_style="SEQUENCE",
payload_field="magnitude",
payload_content="REAL")
# Example 1: Forecast 2 periods based on the model fitted by ArimaEstimate.
# As the fit_percentage is greater than or equal to 100,
# output of ArimaEstimate is used for ArimaForecast.
# Execute ArimaEstimate function.
arima_estimate_op = ArimaEstimate(data1=data_series_df,
nonseasonal_model_order=[2,0,0],
constant=False,
algorithm="MLE",
coeff_stats=True,
fit_metrics=True,
residuals=True,
fit_percentage=100)
# Create teradataml TDAnalyticResult object over the result attribute of 'arima_estimate_op'
data_art_df = TDAnalyticResult(data=arima_estimate_op.result)
uaf_out = ArimaForecast(data=data_art_df,
forecast_periods=2)
# Print the result DataFrame.
print(uaf_out.result)
# Example 2: Forecast 2 periods based on the model fitted by ArimaValidate.
# As the fit_percentage is less than 100,
# output of ArimaEstimate is used for ArimaValidate and
# output of ArimaValidate is used for ArimaForecast.
# Execute ArimaEstimate function.
arima_estimate_op = ArimaEstimate(data1=data_series_df,
nonseasonal_model_order=[2,0,0],
constant=False,
algorithm="MLE",
coeff_stats=True,
fit_metrics=True,
residuals=True,
fit_percentage=80)
# Create TDAnalyticResult object over the result attribute of 'arima_estimate_op'
data_art_df = TDAnalyticResult(data=arima_estimate_op.result)
# Execute ArimaValidate function.
arima_validate_op = ArimaValidate(data=data_art_df,
fit_metrics=TRUE,
residuals=TRUE)
data_art_df1 = TDAnalyticResult(data=arima_validate_op.result)
uaf_out = ArimaForecast(data=data_art_df1,
forecast_periods=2)
# Print the result tbl.
print(uaf_out.result)
|