ExponentialSmoothing#

class cuml.tsa.ExponentialSmoothing(endog, *, seasonal='additive', seasonal_periods=2, start_periods=2, ts_num=1, eps=0.00224, verbose=False, output_type=None)#

Implements a HoltWinters time series analysis model which is used in both forecasting future entries in a time series as well as in providing exponential smoothing, where weights are assigned against historical data with exponentially decreasing impact. This is done by analyzing three components of the data: level, trend, and seasonality.

Parameters:
endogarray-like (device or host)

Acceptable formats: cuDF DataFrame, cuDF Series, NumPy ndarray, Numba device ndarray, cuda array interface compliant array like CuPy. Note: cuDF.DataFrame types assumes data is in columns, while all other datatypes assume data is in rows. The endogenous dataset to be operated on.

seasonal‘additive’, ‘add’, ‘multiplicative’, ‘mul’ (default = ‘additive’)

Whether the seasonal trend should be calculated additively or multiplicatively.

seasonal_periodsint (default=2)

The seasonality of the data (how often it repeats). For monthly data this should be 12, for weekly data, this should be 7.

start_periodsint (default=2)

Number of seasons to be used for seasonal seed values

ts_numint (default=1)

The number of different time series that were passed in the endog param.

epsnp.number > 0 (default=2.24e-3)

The accuracy to which gradient descent should achieve. Note that changing this value may affect the forecasted results.

verboseint or boolean, default=False

Sets logging level. It must be one of cuml.common.logger.level_*. See Verbosity Levels for more info.

output_type{‘input’, ‘array’, ‘dataframe’, ‘series’, ‘df_obj’, ‘numba’, ‘cupy’, ‘numpy’, ‘cudf’, ‘pandas’}, default=None

Return results and set estimator attributes to the indicated output type. If None, the output type set at the module level (cuml.global_settings.output_type) will be used. See Output Data Type Configuration for more info.

Attributes:
SSE
forecasted_points
level
season
trend

Methods

fit(self)

Perform fitting on the given endog dataset.

forecast(self[, h, index])

Forecasts future points based on the fitted model.

get_level(self[, index])

Returns the level component of the model.

get_season(self[, index])

Returns the season component of the model.

get_trend(self[, index])

Returns the trend component of the model.

score(self[, index])

Returns the score of the model.

Notes

Known Limitations: This version of ExponentialSmoothing currently provides only a limited number of features when compared to the statsmodels.holtwinters.ExponentialSmoothing model. Noticeably, it lacks:

Additionally, be warned that there may exist floating point instability issues in this model. Small values in endog may lead to faulty results. See rapidsai/cuml#888 for more information.

Known Differences: This version of ExponentialSmoothing differs from statsmodels in some other minor ways:

  • Cannot pass trend component or damped trend component

  • this version can take additional parameters eps, start_periods, and ts_num

  • Score returns SSE rather than gradient logL rapidsai/cuml#876

  • This version provides get_level(), get_trend(), get_season()

Examples

>>> from cuml import ExponentialSmoothing
>>> import cudf
>>> import cupy as cp
>>> data = cudf.Series([1, 2, 3, 4, 5, 6,
...                     7, 8, 9, 10, 11, 12,
...                     2, 3, 4, 5, 6, 7,
...                     8, 9, 10, 11, 12, 13,
...                     3, 4, 5, 6, 7, 8, 9,
...                     10, 11, 12, 13, 14],
...                     dtype=cp.float64)
>>> cu_hw = ExponentialSmoothing(data, seasonal_periods=12).fit()
>>> cu_pred = cu_hw.forecast(4)
>>> print('Forecasted points:', cu_pred)
Forecasted points :
0    4.000143766093652
1    5.000000163513641
2    6.000000000174092
3    7.000000000000178
fit(self) 'ExponentialSmoothing'[source]#

Perform fitting on the given endog dataset. Calculates the level, trend, season, and SSE components.

forecast(self, h=1, index=None)[source]#

Forecasts future points based on the fitted model.

Parameters:
hint (default=1)

The number of points for each series to be forecasted.

indexint (default=None)

The index of the time series from which you want forecasted points. if None, then a cudf.DataFrame of the forecasted points from all time series is returned.

Returns:
predscudf.DataFrame or cudf.Series

Series of forecasted points if index is provided. DataFrame of all forecasted points if index=None.

get_level(self, index=None)[source]#

Returns the level component of the model.

Parameters:
indexint (default=None)

The index of the time series from which the level will be returned. if None, then all level components are returned in a cudf.Series.

Returns:
levelcudf.Series or cudf.DataFrame

The level component of the fitted model

get_season(self, index=None)[source]#

Returns the season component of the model.

Parameters:
indexint (default=None)

The index of the time series from which the season will be returned. if None, then all season components are returned in a cudf.Series.

Returns:
season: cudf.Series or cudf.DataFrame

The season component of the fitted model

get_trend(self, index=None)[source]#

Returns the trend component of the model.

Parameters:
indexint (default=None)

The index of the time series from which the trend will be returned. if None, then all trend components are returned in a cudf.Series.

Returns:
trendcudf.Series or cudf.DataFrame

The trend component of the fitted model.

score(self, index=None)[source]#

Returns the score of the model.

Note

Currently returns the SSE, rather than the gradient of the LogLikelihood. rapidsai/cuml#876

Parameters:
indexint (default=None)

The index of the time series from which the SSE will be returned. if None, then all SSEs are returned in a cudf Series.

Returns:
scorenp.float32, np.float64, or cudf.Series

The SSE of the fitted model.