hts.model

hts.model.ar

class hts.model.ar.AutoArimaModel(node: hts.hierarchy.HierarchyTree, **kwargs)[source]

Bases: hts.model.base.TimeSeriesModel

Wrapper class around pmdarima.AutoARIMA

Variables:
  • model (pmdarima.AutoARIMA) – The instance of the model
  • mse (float) – MSE for in-sample predictions
  • residual (numpy.ndarry) – Residuals for the in-sample predictions
  • forecast (pandas.DataFramer) – The forecast for the trained model
fit(self, **fit_args)[source]

Fits underlying models to the data, passes kwargs to AutoARIMA

predict(self, node, steps_ahead: int = 10, alpha: float = 0.05)[source]

Predicts the n-step ahead forecast. Exogenous variables are required if models were fit using them

fit(**fit_args) → hts.model.base.TimeSeriesModel[source]
fit_predict(node: hts.hierarchy.HierarchyTree, steps_ahead=10, alpha=0.05, **fit_args)[source]
predict(node, steps_ahead=10, alpha=0.05, exogenous_df: pandas.core.frame.DataFrame = None)[source]
class hts.model.ar.SarimaxModel(node: hts.hierarchy.HierarchyTree, **kwargs)[source]

Bases: hts.model.base.TimeSeriesModel

Wrapper class around statsmodels.tsa.statespace.sarimax.SARIMAX

Variables:
  • model (SARIMAX) – The instance of the model
  • mse (float) – MSE for in-sample predictions
  • residual (numpy.ndarry) – Residuals for the in-sample predictions
  • forecast (pandas.DataFramer) – The forecast for the trained model
fit(self, **fit_args)[source]

Fits underlying models to the data, passes kwargs to SARIMAX

predict(self, node, steps_ahead: int = 10, alpha: float = 0.05)[source]

Predicts the n-step ahead forecast. Exogenous variables are required if models were fit using them

fit(**fit_args) → hts.model.base.TimeSeriesModel[source]
fit_predict(node: hts.hierarchy.HierarchyTree, steps_ahead=10, alpha=0.05, **fit_args)[source]
predict(node, steps_ahead=10, alpha=0.05)[source]

hts.model.base

class hts.model.base.TimeSeriesModel(kind: str, node: hts.hierarchy.HierarchyTree, transform: Union[hts._t.Transform, bool] = False, **kwargs)[source]

Bases: hts._t.TimeSeriesModelT

Base class for the implementation of the underlying models. Inherits from scikit-learn base classes

__init__(kind: str, node: hts.hierarchy.HierarchyTree, transform: Union[hts._t.Transform, bool] = False, **kwargs)[source]
Parameters:
  • kind (str) – One of prophet, sarimax, auto-arima, holt-winters
  • node (HierarchyTree) – Node
  • transform (Bool or NamedTuple) –
  • kwargs – Keyword arguments to be passed to the model instantiation. See the documentation of each of the actual model implementations for a more comprehensive treatment
create_model(**kwargs)[source]
fit(**fit_args) → hts.model.base.TimeSeriesModel[source]
fit_predict(node: hts.hierarchy.HierarchyTree, **kwargs)[source]
predict(node: hts.hierarchy.HierarchyTree, **predict_args)[source]

hts.model.es

class hts.model.es.HoltWintersModel(node: hts.hierarchy.HierarchyTree, **kwargs)[source]

Bases: hts.model.base.TimeSeriesModel

Wrapper class around statsmodels.tsa.holtwinters.ExponentialSmoothing

Variables:
  • model (ExponentialSmoothing) – The instance of the model
  • _model (HoltWintersResults) – The result of model fitting. See statsmodels.tsa.holtwinters.HoltWintersResults
  • mse (float) – MSE for in-sample predictions
  • residual (numpy.ndarry) – Residuals for the in-sample predictions
  • forecast (pandas.DataFramer) – The forecast for the trained model
fit(self, **fit_args)[source]

Fits underlying models to the data, passes kwargs to SARIMAX

predict(self, node, steps_ahead: int = 10)[source]

Predicts the n-step ahead forecast

fit(**fit_args) → hts.model.base.TimeSeriesModel[source]
fit_predict(node: hts.hierarchy.HierarchyTree, steps_ahead=10, **fit_args)[source]
predict(node: hts.hierarchy.HierarchyTree, steps_ahead=10)[source]

hts.model.p

class hts.model.p.FBProphetModel(node: hts.hierarchy.HierarchyTree, **kwargs)[source]

Bases: hts.model.base.TimeSeriesModel

Wrapper class around fbprophet.Prophet

Variables:
  • model (Prophet) – The instance of the model
  • mse (float) – MSE for in-sample predictions
  • residual (numpy.ndarry) – Residuals for the in-sample predictions
  • forecast (pandas.DataFramer) – The forecast for the trained model
fit(self, **fit_args)[source]

Fits underlying models to the data, passes kwargs to fbprophet.Prophet

predict(self, node, steps_ahead: int = 10, freq: str = 'D', **predict_args)[source]

Predicts the n-step ahead forecast. Exogenous variables are required if models were fit using them, frequency should be passed as well

create_model(capacity_max=None, capacity_min=None, **kwargs)[source]
fit(**fit_args) → hts.model.base.TimeSeriesModel[source]
predict(node: hts.hierarchy.HierarchyTree, freq: str = 'D', steps_ahead: int = 1, exogenous_df: pandas.core.frame.DataFrame = None)[source]