GreykiteForecaster
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.
Quickstart
from sktime.forecasting.greykite import GreykiteForecaster
estimator = 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)Parameters(11)
- forecast_configgreykite ForecastConfig or None, default=None
Optional Greykite
ForecastConfigused as the base configuration. If None, a config is built from the flattened parameters below. Prefer the flattened parameters for discoverability; useforecast_configfor 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_configis None; otherwise setforecast_config.model_templateinstead.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 viamodel_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, andSILVERKITE_HOURLY_{1,24,168,336}. These use hyperparameters tuned for that frequency and horizon. See greykiteModelTemplateEnumfor the full list [2].- coveragefloat, default=0.95
Intended coverage of prediction bands, between 0 and 1. Used only when
forecast_configis None; otherwise setforecast_config.coverageinstead. 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).
Trueuses the full horizon as one segment; an int is a segment size; a list of ints must sum to the horizon. If None andforecast_configis None, defaults to False; ifforecast_configis 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 ofywhen possible. Maps toMetadataParam.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 emptyModelComponentsParamis used and the chosenmodel_templatesupplies component defaults. When a dict (or list of dicts for grid search), recognized keys are:growthdict, default=NoneTrend / growth terms. Template default 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 (
EvaluationMetricEnummember name).
- 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 horizonHoldout length at the end of the series. Set to
0to skip backtest. Greykite default when unset is the forecast horizon.
- 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=1Parallel jobs for hyperparameter search (
-1uses all processors).
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)