Skip to content

GreykiteForecaster

GreykiteForecaster

class GreykiteForecaster(forecast_config: GreykiteForecaster.ForecastConfig | None = None, date_format: str | None = None, model_template: str = 'SILVERKITE', coverage: float = 0.95, forecast_one_by_one=None, freq=None, anomaly_info=None, model_components_param=None, evaluation_metric_param=None, evaluation_period_param=None, computation_param=None)[source]

Adapter for using Greykite forecasting models within sktime.

This forecaster wraps Greykite forecast_pipeline and exposes a sktime-compatible API.

WARNING: the greykite package has very restrictive dependencies that typically prevent installation together with other packages. For this reason, this estimator is also not covered by regular tests. We therefore recommend to run check_estimator(GreykiteForecaster) on your system before deploying this estimator.

Parameters:
forecast_configgreykite ForecastConfig or None, default=None

Optional Greykite ForecastConfig used as the base configuration. If None, a config is built from the flattened parameters below. Prefer the flattened parameters for discoverability; use forecast_config for advanced setups or when migrating existing Greykite code.

date_formatstr or None, default=None

Format string for parsing timestamps (e.g. "%Y-%m-%d"). If None, Greykite infers the format.

model_templatestr, default=”SILVERKITE”

Greykite model template name. Used only when forecast_config is None; otherwise set forecast_config.model_template instead.

Main templates:

  • "SILVERKITE" - default Silverkite model with automatic growth, seasonality, holidays, autoregression, and interactions. Good general choice for hourly and daily data.

  • "PROPHET" - Facebook Prophet with growth, seasonality, holidays, regressors, and prediction intervals.

  • "AUTO_ARIMA" - ARIMA with automatic order selection.

  • "AUTO" - automatically selects a SimpleSilverkite template from data frequency, forecast horizon, and CV settings.

  • "SILVERKITE_EMPTY" - intercept-only Silverkite; add only the components you need via model_components_param.

  • "SK" - low-level Silverkite interface for custom tuning; not intended out-of-the-box.

  • "LAG_BASED" - forecasts from aggregated past values (e.g. week-over-week).

  • "SILVERKITE_TWO_STAGE" / "SILVERKITE_WOW" - multistage models (long-term effects then short-term residuals, or Silverkite plus week-over-week).

Frequency / horizon variants of Silverkite also exist, for example SILVERKITE_DAILY_1, SILVERKITE_DAILY_90, SILVERKITE_WEEKLY, SILVERKITE_MONTHLY, and SILVERKITE_HOURLY_{1,24,168,336}. These use hyperparameters tuned for that frequency and horizon. See greykite ModelTemplateEnum for the full list [2].

coveragefloat, default=0.95

Intended coverage of prediction bands, between 0 and 1. Used only when forecast_config is None; otherwise set forecast_config.coverage instead. If None on the config, Greykite does not return upper/lower prediction bounds.

forecast_one_by_onebool, int, list of int, or None, default=None

If set, enables Greykite’s one-by-one forecasting (fit/predict in segments of the horizon). True uses the full horizon as one segment; an int is a segment size; a list of ints must sum to the horizon. If None and forecast_config is None, defaults to False; if forecast_config is provided, that config’s value is kept.

freqstr or None, default=None

Pandas frequency string for the series (e.g. "D", "H"). If None, inferred from the index of y when possible. Maps to MetadataParam.freq.

anomaly_infodict, list of dict, or None, default=None

Optional anomaly adjustment specification. Values flagged here are corrected before fitting. Maps to MetadataParam.anomaly_info.

model_components_paramdict, ModelComponentsParam, list, or None, default=None

Model structure and tuning options passed to Greykite ModelComponentsParam. If None, an empty ModelComponentsParam is used and the chosen model_template supplies component defaults. When a dict (or list of dicts for grid search), recognized keys are:

  • growthdict, default=None

    Trend / growth terms. Template default if omitted.

  • seasonalitydict, default=None

    Seasonal Fourier or dummy terms. Template default if omitted.

  • eventsdict, default=None

    Holidays and other event effects. Template default if omitted.

  • changepointsdict, default=None

    Trend changepoint placement and strength. Template default if omitted.

  • autoregressiondict, default=None

    Lagged value terms. Template default if omitted.

  • regressorsdict, default=None

    Contemporaneous exogenous regressors. Template default if omitted.

  • lagged_regressorsdict, default=None

    Lagged exogenous regressors. Template default if omitted.

  • uncertaintydict, default=None

    Prediction-interval / uncertainty model. Template default if omitted.

  • customdict, default=None

    Template-specific extra options. Template default if omitted.

  • hyperparameter_overridedict or list of dict, default=None

    Applied on top of the template hyperparameter grid for full customization. No override if omitted.

evaluation_metric_paramdict, EvaluationMetricParam, or None, default=None

Metrics used for CV reporting and model selection. Passed to Greykite EvaluationMetricParam. If None, an empty param object is used and Greykite pipeline defaults apply. When a dict, recognized keys are:

  • cv_selection_metricstr, default=”MeanAbsolutePercentError”

    Metric name used to pick the best CV model (EvaluationMetricEnum member name).

  • cv_report_metricsstr or list of str, default=”ALL”

    Extra metric name(s) reported during CV. "ALL" computes all EvaluationMetricEnum metrics.

  • agg_periodsint, default=None

    Optional number of periods to aggregate before scoring. No aggregation if None.

  • agg_funccallable, default=None

    Aggregation function used with agg_periods (e.g. np.sum). Ignored if agg_periods is None.

  • null_model_paramsdict, default=None

    Configuration for Greykite’s null model baseline comparison (DummyRegressor keys such as strategy). If None, R2_null_model_score is not computed.

  • relative_error_tolerancefloat, default=None

    Relative error threshold for the outside-tolerance metric (e.g. 0.05 for 5%). If None, that metric is not computed.

evaluation_period_paramdict, EvaluationPeriodParam, or None, default=None

Train/test and cross-validation split configuration. Passed to Greykite EvaluationPeriodParam. If None, an empty param object is used and Greykite pipeline defaults apply. When a dict, recognized keys are:

  • test_horizonint, default=forecast horizon

    Holdout length at the end of the series. Set to 0 to skip backtest. Greykite default when unset is the forecast horizon.

  • periods_between_train_testint, default=0

    Gap between train and test. Greykite default when unset is 0.

  • cv_horizonint, default=forecast horizon

    Forecast horizon used inside each CV fold. Set to 0 (or cv_max_splits=0) to skip CV. Greykite default when unset is the forecast horizon.

  • cv_max_splitsint, default=3

    Maximum number of CV splits. None uses all splits.

  • cv_min_train_periodsint, default=2 * cv_horizon

    Minimum training length per split. Greykite default when unset is 2 * cv_horizon.

  • cv_periods_between_splitsint, default=cv_horizon

    Step size between CV split starts. Greykite default when unset is cv_horizon.

  • cv_periods_between_train_testint, default=periods_between_train_test

    Gap between CV train and test. Greykite default when unset mirrors periods_between_train_test.

  • cv_expanding_windowbool, default=True

    If True, use expanding rather than sliding training windows.

  • cv_use_most_recent_splitsbool, default=False

    If True, prefer recent splits when capping cv_max_splits. Greykite default when unset is False.

computation_paramdict, ComputationParam, or None, default=None

Runtime / parallelization options. Passed to Greykite ComputationParam. If None, an empty param object is used and Greykite pipeline defaults apply. When a dict, recognized keys are:

  • n_jobsint, default=1

    Parallel jobs for hyperparameter search (-1 uses all processors).

  • hyperparameter_budgetint, default=None

    Max hyperparameter combinations to evaluate. None means full grid search when the grid is discrete, or 10 samples when any value is a distribution.

  • verboseint, default=1

    Verbosity level for fitting and CV logs.

Attributes:
_forecasterobject

The fitted Greykite forecaster.

_forecastpandas.DataFrame

The forecast result from the Greykite model.

_Xpandas.DataFrame

The exogenous variables, if provided.

Notes

  • Greykite ForecastConfig fields are available either via a forecast_config object or as flattened constructor parameters.

  • If forecast_config is provided, it is used as the base configuration.

  • Flattened parameters whose default is None override the corresponding fields on that object when set.

  • model_template and coverage are applied only when forecast_config is None, so their defaults do not overwrite values already set on a user-provided config.

  • To change those fields when passing forecast_config, set them on the config object itself.

  • The time index of y and X can be any format recognized by pandas.to_datetime. If conversion fails, a default daily DatetimeIndex starting at 2000-01-01 is created for Greykite internally.

References

Examples

>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.greykite import GreykiteForecaster
>>> from sktime.forecasting.base import ForecastingHorizon
>>> y = load_airline().to_timestamp()
>>> fh = ForecastingHorizon([1, 2, 3])
>>> forecaster = GreykiteForecaster()
>>> forecaster.fit(y=y, fh=fh)
>>> y_pred = forecaster.predict(fh=fh)

Methods

check_is_fitted([method_name])

Check if the estimator has been fitted.

clone()

Obtain a clone of the object with same hyper-parameters and config.

clone_tags(estimator[, tag_names])

Clone tags from another object as dynamic override.

create_test_instance([parameter_set])

Construct an instance of the class, using first test parameter set.

create_test_instances_and_names([parameter_set])

Create list of all test instances and a list of names for them.

fit(y[, X, fh])

Fit forecaster to training data.

fit_predict(y[, X, fh, X_pred])

Fit and forecast time series at future horizon.

get_class_tag(tag_name[, tag_value_default])

Get class tag value from class, with tag level inheritance from parents.

get_class_tags()

Get class tags from class, with tag level inheritance from parent classes.

get_config()

Get config flags for self.

get_fitted_params([deep])

Get fitted parameters.

get_param_defaults()

Get object's parameter defaults.

get_param_names([sort])

Get object's parameter names.

get_params([deep])

Get a dict of parameters values for this object.

get_pretrained_params([deep])

Get pretrained parameters of this estimator.

get_tag(tag_name[, tag_value_default, ...])

Get tag value from instance, with tag level inheritance and overrides.

get_tags()

Get tags from instance, with tag level inheritance and overrides.

get_test_params([parameter_set])

Return testing parameter settings for the GreykiteForecaster.

is_composite()

Check if the object is composed of other BaseObjects.

load_from_path(serial)

Load object from file location.

load_from_serial(serial)

Load object from serialized memory container.

predict([fh, X])

Forecast time series at future horizon.

predict_interval([fh, X, coverage])

Compute/return prediction interval forecasts.

predict_proba([fh, X, marginal])

Compute/return fully probabilistic forecasts.

predict_quantiles([fh, X, alpha])

Compute/return quantile forecasts.

predict_residuals([y, X])

Return residuals of time series forecasts.

predict_var([fh, X, cov])

Compute/return variance forecasts.

pretrain(y[, X, fh])

Pre-train forecaster on panel (global) data.

reset()

Reset the object to a clean post-init state.

save([path, serialization_format])

Save serialized self to bytes-like object or to (.zip) file.

score(y[, X, fh])

Scores forecast against ground truth, using MAPE (non-symmetric).

set_config(**config_dict)

Set config flags to given values.

set_params(**params)

Set the parameters of this object.

set_random_state([random_state, deep, ...])

Set random_state pseudo-random seed parameters for self.

set_tags(**tag_dict)

Set instance level tag overrides to given values.

update(y[, X, update_params])

Update cutoff value and, optionally, fitted parameters.

update_predict(y[, cv, X, update_params, ...])

Make predictions and update model iteratively over the test set.

update_predict_single([y, fh, X, update_params])

Update model with new data and make forecasts.