OnlineARIMA
- class hana_ml.algorithms.pal.tsa.online_algorithms.OnlineARIMA(order=None, learning_rate=None, epsilon=None, output_fitted=True, random_state=None, random_initialization=None)
Online ARIMA implements an online learning method to estimate the parameters of ARIMA models by reformulating it into a full information online optimization task (without random noise terms), which has no limitations of depending on noise terms and accessing the entire large-scale dataset in advance.
- Parameters:
- order(p, d, m), tuple of int, optional
p: value of the auto regression order.
d: value of the differentiation order.
m: extended order needed to transform all moving-averaging term to AR term.
Defaults to (1, 0, 0).
- learning_ratefloat, optional
Learning rate. Must be greater than zero.
Calculated according to
order(p, d, m)
.- epsilonfloat, optional
Convergence criterion.
Calculated according to
learning_rate
,p
andm
in the order.- output_fittedbool, optional
Output fitted result and residuals if True.
Defaults to True.
- random_stateint, optional
Specifies the seed for random number generator.
0: use the current time (in second) as seed.
Others: use the specified value as seed.
Default to 0.
- random_initializationbool, optional
Whether randomly generate initial state
False: set all to zero.
True: use random values.
Defaults to False.
Examples
>>> arima = OnlineARIMA(order=(4,0,8), output_fitted=True, learning_rate=0.00001) >>> res = arima1.partial_fit(data=df, key='TIMESTAMP')
- Attributes:
- model_DataFrame
Model content.
- fitted_DateFrame
Fitted values and residuals.
Methods
partial_fit
(data[, key, endog])Generates a ARIMA model with given data.
predict
([forecast_length, allow_new_index])Generates time series forecasts based on the fitted model.
set_conn
(connection_context)Set connection context for an OnlineARIMA instance.
- set_conn(connection_context)
Set connection context for an OnlineARIMA instance.
- Parameters:
- connection_contextConnectionContext
The connection to the SAP HANA system.
- Returns:
- None.
- partial_fit(data, key=None, endog=None, **kwargs)
Generates a ARIMA model with given data.
- Parameters:
- dataDataFrame
DataFrame containing the data.
- keystr, optional
The timestamp column of data. The type of key column is int.
Defaults to the first column of data if the index column of data is not provided. Otherwise, defaults to the index column of data.
- endogstr, optional
The endogenous variable, i.e. time series.
Defaults to the first non-key column of data if not provided.
- **kwargskeyword arguments, optional
The value of
learning_rate
andepsilon
could be reset in the model.For example, assume we have a OnlineARIMA object oa and we want to reset the value of
learning_rate
in the new training, then we can run>>> oa.partial_fit(new_data, learning_rate=0.02)
- Returns:
- A fitted object of class "OnlineARIMA".
- predict(forecast_length=None, allow_new_index=False)
Generates time series forecasts based on the fitted model.
- Parameters:
- forecast_lengthint, optional
Forecast horizon, i.e. number of future points to forecast.
Defaults to 1.
- allow_new_indexbool, optional
Indicates whether a new index column is allowed in the result.
True: return the result with new integer or timestamp index column.
False: return the result with index column starting from 0.
Defaults to False.
- Returns:
- DataFrame
Prediction result, i.e. forecasted values within specified horizon, structured as follows:
1st column : timestamp
2nd column : forecast value
Inherited Methods from PALBase
Besides those methods mentioned above, the OnlineARIMA class also inherits methods from PALBase class, please refer to PAL Base for more details.