SsaForecaster Class
This transform forecasts using Singular Spectrum Analysis (SSA).
- Inheritance
-
nimbusml.internal.core.timeseries._ssaforecaster.SsaForecasterSsaForecasternimbusml.base_transform.BaseTransformSsaForecastersklearn.base.TransformerMixinSsaForecaster
Constructor
SsaForecaster(window_size=0, series_length=0, train_size=0, horizon=0, confidence_level=0.95, variable_horizon=False, confidence_lower_bound_column=None, confidence_upper_bound_column=None, rank_selection_method='Exact', rank=None, max_rank=None, should_stabilize=True, should_maintain_info=False, max_growth=None, discount_factor=1.0, is_adaptive=False, columns=None, **params)
Parameters
- columns
see Columns.
- window_size
The length of the window on the series for building the trajectory matrix (parameter L).
- series_length
The length of series that is kept in buffer for modeling (parameter N).
- train_size
The length of series from the begining used for training.
- horizon
The number of values to forecast.
- confidence_level
The confidence level in [0, 1) for forecasting.
- variable_horizon
Set this to true horizon will change at prediction time.
- confidence_lower_bound_column
The name of the confidence interval lower bound column.
- confidence_upper_bound_column
The name of the confidence interval upper bound column.
- rank_selection_method
The rank selection method.
- rank
The desired rank of the subspace used for SSA projection (parameter r). This parameter should be in the range in [1, windowSize]. If set to null, the rank is automatically determined based on prediction error minimization.
- max_rank
The maximum rank considered during the rank selection process. If not provided (i.e. set to null), it is set to windowSize - 1.
- should_stabilize
The flag determining whether the model should be stabilized.
- should_maintain_info
The flag determining whether the meta information for the model needs to be maintained.
- max_growth
The maximum growth on the exponential trend.
- discount_factor
The discount factor in [0,1] used for online updates.
- is_adaptive
The flag determing whether the model is adaptive.
- params
Additional arguments sent to compute engine.
Examples
###############################################################################
# SsaForecaster
import numpy as np
import pandas as pd
from nimbusml.timeseries import SsaForecaster
# This example creates a time series (list of data with the
# i-th element corresponding to the i-th time slot).
# Generate sample series data with a recurring pattern
seasonality_size = 5
seasonal_data = np.arange(seasonality_size)
data = np.tile(seasonal_data, 3)
X_train = pd.Series(data, name="ts")
# X_train looks like this
# 0 0
# 1 1
# 2 2
# 3 3
# 4 4
# 5 0
# 6 1
# 7 2
# 8 3
# 9 4
# 10 0
# 11 1
# 12 2
# 13 3
# 14 4
x_test = X_train.copy()
x_test[-3:] = [100, 110, 120]
# x_test looks like this
# 0 0
# 1 1
# 2 2
# 3 3
# 4 4
# 5 0
# 6 1
# 7 2
# 8 3
# 9 4
# 10 0
# 11 1
# 12 100
# 13 110
# 14 120
training_seasons = 3
training_size = seasonality_size * training_seasons
forecaster = SsaForecaster(series_length=8,
train_size=training_size,
window_size=seasonality_size + 1,
horizon=4) << {'fc': 'ts'}
forecaster.fit(X_train, verbose=1)
data = forecaster.transform(x_test)
pd.set_option('display.float_format', lambda x: '%.2f' % x)
print(data)
# The fc.x columns are the forecasts
# given the input in the ts column.
#
# ts fc.0 fc.1 fc.2 fc.3
# 0 0 1.00 2.00 3.00 4.00
# 1 1 2.00 3.00 4.00 -0.00
# 2 2 3.00 4.00 -0.00 1.00
# 3 3 4.00 -0.00 1.00 2.00
# 4 4 -0.00 1.00 2.00 3.00
# 5 0 1.00 2.00 3.00 4.00
# 6 1 2.00 3.00 4.00 -0.00
# 7 2 3.00 4.00 -0.00 1.00
# 8 3 4.00 -0.00 1.00 2.00
# 9 4 -0.00 1.00 2.00 3.00
# 10 0 1.00 2.00 3.00 4.00
# 11 1 2.00 3.00 4.00 -0.00
# 12 100 3.00 4.00 0.00 1.00
# 13 110 4.00 -0.00 1.00 75.50
# 14 120 -0.00 1.00 83.67 83.25
Remarks
This class implements the transform based on Singular Spectrum Analysis (SSA). SSA is a powerful framework for decomposing the time-series into trend, seasonality and noise components as well as forecasting the future values of the time-series. In principle, SSA performs spectral analysis on the input time-series where each component in the spectrum corresponds to a trend, seasonal or noise component in the time-series. For details of the Singular Spectrum Analysis (SSA), refer to this document.
Methods
get_params |
Get the parameters for this operator. |
get_params
Get the parameters for this operator.
get_params(deep=False)
Parameters
- deep