gloria.Gloria#

class gloria.Gloria(*args, model='normal', sampling_period=Timedelta('1 days 00:00:00'), timestamp_name='ds', metric_name='y', capacity_name='', changepoints=None, n_changepoints=25, changepoint_range=0.8, seasonality_prior_scale=3, event_prior_scale=3, changepoint_prior_scale=3, dispersion_prior_scale=3, interval_width=0.8, trend_samples=1000, **kwargs)[source]#

The Gloria forecaster object is the central hub for the entire modeling workflow.

Gloria objects are initialized with parameters controlling the fit and prediction behaviour. Features such as seasonalities, external regressors, and events (or collection of such using protocols) are added to Gloria objects. Once set up, fit(), predict(), or plot() methods are available to fit the model to input data and visualize the results.

Parameters:
  • model (str) – The distribution model to be used. Can be any of "poisson", "binomial", "negative binomial", "gamma", "beta", "beta-binomial", or "normal". See Model Selection tutorial for further information.

  • sampling_period (Union[pd.Timedelta, str]) – Minimum spacing between two adjacent samples either as pd.Timedelta or a compatible string such as "1d" or "20 min".

  • timestamp_name (str, optional) – The name of the timestamp column as expected in the input data frame for fit().

  • metric_name (str, optional) – The name of the expected metric column of the input data frame for fit().

  • capacity_name (str, optional) – The name of the column containing capacity data for the models "binomial" and "beta-binomial".

  • changepoints (pd.Series, optional) – List of timestamps at which to include potential changepoints. If not specified (default), potential changepoints are selected automatically.

  • n_changepoints (int, optional) – Number of potential changepoints to include. Not used if input ‘changepoints’ is supplied. If changepoints is not supplied, then n_changepoints potential changepoints are selected uniformly from the first changepoint_range proportion of the history. Must be a positive integer.

  • changepoint_range (float, optional) – Proportion of history in which trend changepoints will be estimated. Must be in range [0,1]. Not used if changepoints is specified.

  • seasonality_prior_scale (float, optional) – Parameter modulating the strength of the seasonality model. Larger values allow the model to fit larger seasonal fluctuations, smaller values dampen the seasonality. Can be specified for individual seasonalities using add_seasonality(). Must be larger than 0.

  • event_prior_scale (float, optional) – Parameter modulating the strength of additional event regressors. Larger values allow the model to fit larger event impact, smaller values dampen the event impact. Can be specified for individual events using add_event(). Must be larger than 0.

  • changepoint_prior_scale (float, optional) – Parameter modulating the flexibility of the automatic changepoint selection. Large values will allow many changepoints, small values will allow few changepoints. Must be larger than 0.

  • dispersion_prior_scale (float, optional) – Parameter controlling the flexibility of the dispersion (i.e. allowed variance) of the model. Larger values allow more dispersion. This parameter does not affect the binomial and poisson model. Must be larger than one.

  • interval_width (float, optional) – Width of the uncertainty intervals provided for the prediction. It is used for both uncertainty intervals of the expected value (fit) as well as the observed values (observed). Must be in range [0,1].

  • trend_samples (int, optional) – Number of simulated draws used to estimate uncertainty intervals of the trend in prediction periods that were not included in the historical data. Settings this value to 0 will disable uncertainty estimation. Must be greater equal to 0.

  • args (tuple[Any, ...])

  • kwargs (dict[str, Any])

Attributes

is_fitted

Determines whether the present Gloria model is fitted.

Methods

add_event(name, regressor_type, profile[, ...])

Adds an event to the Gloria object.

add_external_regressor(name, prior_scale)

Add an external regressor to the Gloria object.

add_protocol(protocol)

Add a protocol to the Gloria object.

add_seasonality(name, period, fourier_order)

Adds a seasonality to the Gloria object.

fit(data[, toml_path])

Fits the Gloria object.

from_dict(model_dict)

Restores a fitted Gloria model from a dictionary.

from_json(model_json[, return_as])

Restores a fitted Gloria model from a json string or file.

from_toml(toml_path[, ignore])

Instantiate and configure a Gloria object from a TOML configuration file.

load_data([toml_path])

Load and configure the time-series input data for fit method.

make_future_dataframe([periods, include_history])

Build a timestamp skeleton that extends the training horizon.

plot(fcst[, ax, uncertainty, ...])

Plot the forecast, trend, and observed data with extensive customization options.

plot_components(fcst[, uncertainty, ...])

Plot forecast components of a Gloria model using a modern Seaborn style, with global kwargs applied to all subplots.

predict([data, toml_path])

Generate forecasts from a fitted Gloria model.

to_dict()

Converts Gloria object to a dictionary of JSON serializable types.

to_json([filepath])

Converts Gloria object to a JSON string.