mojolearn.OptimizedTheta#
- class mojolearn.OptimizedTheta(season_length=1, decomposition_type='multiplicative', model=None, initial_smoothed=None, alpha=None, theta=None, numeric_mode=None)[source]#
Bases:
AutoThetaThe optimized theta model (OTM). Follows statsforecast’s
OptimizedTheta.fittakes one series of shape(n_obs,)or a batch of shape(batch_size, n_obs); the model is estimated when predict() is called.- Parameters:
season_length (int, default 1) – Number of observations per season. 1 means no seasonality.
decomposition_type ({“multiplicative”, “additive”}, default “multiplicative”) – Seasonal decomposition used when the series tests as seasonal.
model (ignored) – This class always uses the OTM model; the argument is accepted for signature compatibility with
AutoTheta.initial_smoothed (float or None, default None) – Fixes the initial smoothed level; None estimates it.
alpha (float or None, default None) – Fixes the smoothing parameter; None estimates it.
theta (float or None, default None) – Fixes the theta coefficient; None estimates it.
numeric_mode (str or None, default None) – Numeric mode for this model (
'identical','deterministic'or'fast'); None uses the process default (seemojolearn.set_numeric_mode()).
- Variables:
Notes
Input must be float32; float64 raises TypeError. Each series needs more than 3 observations. Prediction intervals (
level), fitted values, non-normal error distributions and exogenous regressors are not supported and raise NotImplementedError.Examples
>>> import numpy as np, mojolearn >>> t = np.arange(96, dtype=np.float32) >>> y = 10 + 0.1 * t + np.sin(2 * np.pi * t / 12).astype(np.float32) >>> mojolearn.OptimizedTheta(season_length=12).fit(y).predict(12)["mean"].shape (12,)
- __init__(season_length=1, decomposition_type='multiplicative', model=None, initial_smoothed=None, alpha=None, theta=None, numeric_mode=None)#
Methods
fit(y[, X])Store one series or a batch of series for forecasting.
forecast(y, h[, X, X_future, level, fitted])Fit
yand forecasthsteps in one call.predict(h[, X, level])Fit the theta model and forecast h steps ahead.