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_pipelineand exposes a sktime-compatible API.WARNING: the
greykitepackage 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 runcheck_estimator(GreykiteForecaster)on your system before deploying this estimator.- Parameters:
- 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.
seasonalitydict, default=NoneSeasonal Fourier or dummy terms. Template default if omitted.
eventsdict, default=NoneHolidays and other event effects. Template default if omitted.
changepointsdict, default=NoneTrend changepoint placement and strength. Template default if omitted.
autoregressiondict, default=NoneLagged value terms. Template default if omitted.
regressorsdict, default=NoneContemporaneous exogenous regressors. Template default if omitted.
lagged_regressorsdict, default=NoneLagged exogenous regressors. Template default if omitted.
uncertaintydict, default=NonePrediction-interval / uncertainty model. Template default if omitted.
customdict, default=NoneTemplate-specific extra options. Template default if omitted.
hyperparameter_overridedict or list of dict, default=NoneApplied 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 (
EvaluationMetricEnummember name).
cv_report_metricsstr or list of str, default=”ALL”Extra metric name(s) reported during CV.
"ALL"computes allEvaluationMetricEnummetrics.
agg_periodsint, default=NoneOptional number of periods to aggregate before scoring. No aggregation if None.
agg_funccallable, default=NoneAggregation function used with
agg_periods(e.g.np.sum). Ignored ifagg_periodsis None.
null_model_paramsdict, default=NoneConfiguration for Greykite’s null model baseline comparison (
DummyRegressorkeys such asstrategy). If None,R2_null_model_scoreis not computed.
relative_error_tolerancefloat, default=NoneRelative error threshold for the outside-tolerance metric (e.g.
0.05for 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 horizonHoldout length at the end of the series. Set to
0to skip backtest. Greykite default when unset is the forecast horizon.
periods_between_train_testint, default=0Gap between train and test. Greykite default when unset is
0.
cv_horizonint, default=forecast horizonForecast horizon used inside each CV fold. Set to
0(orcv_max_splits=0) to skip CV. Greykite default when unset is the forecast horizon.
cv_max_splitsint, default=3Maximum number of CV splits.
Noneuses all splits.
cv_min_train_periodsint, default=2 * cv_horizonMinimum training length per split. Greykite default when unset is
2 * cv_horizon.
cv_periods_between_splitsint, default=cv_horizonStep size between CV split starts. Greykite default when unset is
cv_horizon.
cv_periods_between_train_testint, default=periods_between_train_testGap between CV train and test. Greykite default when unset mirrors
periods_between_train_test.
cv_expanding_windowbool, default=TrueIf True, use expanding rather than sliding training windows.
cv_use_most_recent_splitsbool, default=FalseIf True, prefer recent splits when capping
cv_max_splits. Greykite default when unset isFalse.
- 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).
hyperparameter_budgetint, default=NoneMax 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=1Verbosity 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
ForecastConfigfields are available either via aforecast_configobject or as flattened constructor parameters.If
forecast_configis provided, it is used as the base configuration.Flattened parameters whose default is
Noneoverride the corresponding fields on that object when set.model_templateandcoverageare applied only whenforecast_configisNone, 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
yandXcan be any format recognized bypandas.to_datetime. If conversion fails, a default dailyDatetimeIndexstarting at2000-01-01is 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.

