API Reference / algorithms / timeseries /

exponential_smoothing.py

Exponential Smoothing models for time series forecasting.

Classes

ExponentialSmoothing

class algorithms.timeseries.exponential_smoothing.ExponentialSmoothing(Regressor)

Exponential Smoothing model for time series forecasting with trend and seasonal components.

Exponential smoothing is a family of forecasting methods that use weighted averages of past observations, with weights decreasing exponentially as the observations get older. This implementation supports Simple (SES), Double (Holt's), and Triple (Holt-Winters) exponential smoothing.
Constructor
__init__(
    self,
    trend: str | None = None,
    seasonal: str | None = None,
    seasonal_periods: int | None = None,
    smoothing_level: float | None = None,
    smoothing_trend: float | None = None,
    smoothing_seasonal: float | None = None,
    damped_trend: bool = False,
)

Overview

The Exponential Smoothing procedure works as follows:

  1. Select the model type: Simple (no trend/season), Double (trend),
or Triple (trend + seasonality).
  1. Initialize the level, trend, and seasonal components from the data.
  2. Apply the recursive smoothing equations to update each component
at every time step using smoothing parameters \alpha, \beta, and \gamma.
  1. Compute fitted values and residuals from the one-step-ahead
forecasts during training.
  1. Generate multi-step forecasts by extrapolating the final level,
trend, and seasonal components.

Theory

Simple Exponential Smoothing (SES): Suitable for data with no clear trend or seasonal pattern.

\hat{y}_{t+1} = \alpha y_t + (1 - \alpha) \hat{y}_t

Double Exponential Smoothing (Holt's Linear Trend): Adds a trend component to SES.

\begin{aligned} \ell_t &= \alpha y_t + (1 - \alpha)(\ell_{t-1} + b_{t-1}) \ b_t &= \beta (\ell_t - \ell_{t-1}) + (1 - \beta) b_{t-1} \ \hat{y}_{t+h} &= \ell_t + h b_t \end{aligned}

Triple Exponential Smoothing (Holt-Winters): Adds a seasonal component to Holt's method. Supports both additive and multiplicative seasonality.

Additive Seasonality:

\begin{aligned} \ell_t &= \alpha (y_t - s_{t-m}) + (1 - \alpha)(\ell_{t-1} + b_{t-1}) \ b_t &= \beta (\ell_t - \ell_{t-1}) + (1 - \beta) b_{t-1} \ s_t &= \gamma (y_t - \ell_{t-1} - b_{t-1}) + (1 - \gamma) s_{t-m} \ \hat{y}_{t+h} &= \ell_t + h b_t + s_{t-m+h_m} \end{aligned}

Parameters

trend
{"add", "mul", None} = None
Type of trend component.
seasonal
{"add", "mul", None} = None
Type of seasonal component.
seasonal_periods
int = None
Number of periods in a season (e.g., 12 for monthly data).
smoothing_level
float = None
The alpha (:math:`\\alpha`) parameter for the level.
smoothing_trend
float = None
The beta (:math:`\\beta`) parameter for the trend.
smoothing_seasonal
float = None
The gamma (:math:`\gamma`) parameter for the seasonal component.
damped_trend
bool = False
Whether to dampen the trend over time.

Attributes

level_
float
The final level component.
trend_
float or None
The final trend component.
seasonal_
np.ndarray or None
The final seasonal components.
params_
dict
The smoothing parameters used.
fitted_values_
np.ndarray
The values fitted to the training data.
resid_
np.ndarray
The residuals from the fitted model.
n_obs_
int
The number of observations in the training data.

Notes

Complexity:

  • Training: O(n) where n is the number of samples.
  • Prediction: O(h) where h is the forecast horizon.
When to use ExponentialSmoothing:
  • Time series with trend and/or seasonal patterns
  • When recent observations should carry more weight than older ones
  • Short-to-medium term forecasting with limited data
  • Business and demand forecasting applications
  • When a simple, fast, and interpretable model is desired

References

Hyndman2008
Hyndman, R. J., Koehler, A. B., Ord, J. K., & Snyder, R. D. (2008). Forecasting with exponential smoothing: the state space approach. Springer Science & Business Media.
Gardner2006
Gardner Jr, E. S. (2006). Exponential smoothing: The state of the art. Journal of Forecasting, 25(4), 637-666.
python
>>> import numpy as np
>>> from tuiml.algorithms.timeseries import ExponentialSmoothing
>>> # Generating data with trend
>>> y = np.array([2, 4, 6, 8, 10, 12, 14, 16, 18, 20], dtype=float)
>>> model = ExponentialSmoothing(trend="add")
>>> model.fit(y)
>>> forecast = model.predict(steps=3)

Methods

get_parameter_schema (cls) -> Dict[str, Dict[str, Any]]

Return JSON Schema for algorithm parameters.

get_capabilities (cls) -> List[str]

Return supported capabilities.

get_complexity (cls) -> str

Return complexity analysis.

get_references (cls) -> List[str]

Return academic citations.

fit (self, y: np.ndarray, X: Optional[np.ndarray]=None) -> 'ExponentialSmoothing'

Fit the exponential smoothing model to time series data.

Parameters
y
np.ndarray of shape (n_samples,)
Time series values to fit.
X
np.ndarray = None
Ignored. Present for API consistency with regressors.
Returns
self
ExponentialSmoothing
Fitted estimator.
predict (self, steps: int=1, X: Optional[np.ndarray]=None) -> np.ndarray

Forecast future values using the fitted smoothing model.

Parameters
steps
int = 1
Number of future time steps to forecast.
X
np.ndarray = None
Ignored. Present for API consistency with regressors.
Returns
forecast
np.ndarray of shape (steps,)
Forecasted values.
fit_predict (self, y: np.ndarray, steps: int=1) -> np.ndarray

Fit the model and forecast future values in one step.

Parameters
y
np.ndarray of shape (n_samples,)
Time series values to fit.
steps
int = 1
Number of future time steps to forecast.
Returns
forecast
np.ndarray of shape (steps,)
Forecasted values.