kats.utils.emp_confidence_int module¶
The Empirical Confidence (Prediction) Interval
This is an empirical way to estimate the prediction interval for any forecasting models The high level idea is to estimate the empirical error distributions from a specific forecasting model, and use linear regression model to fit the standard error (S.E.) with the time horizon, under the assumption that longer horizon has larger S.E.
- class kats.utils.emp_confidence_int.EmpConfidenceInt(error_methods: List[str], data: kats.consts.TimeSeriesData, params: kats.consts.Params, train_percentage: float, test_percentage: float, sliding_steps: int, model_class, multi=True, confidence_level: float = 0.8, **kwargs)[source]¶
Bases:
object
“class for empirical confidence interval
The steps are listed as follows: 1. Run K-fold CV for a given model and data,
each fold contains h (horizon) time ahead
For each horizon, calculate the Std of K error terms (S.E)
Fit linear model: S.E. ~ Horizon
Estimate the S.E. for each horizon for the true future
Lower/Upper = Point Estimate -/+ Z_Score * S.E.
- error_method¶
list of strings indicating which errors to calculate we currently support “mape”, “smape”, “mae”, “mase”, “mse”, “rmse”
- data¶
the time series data in TimeSeriesData format
- params¶
the Kats model parameter object
- train_percentage¶
percentage of data used for training
- test_percentage¶
percentage of data used for testing
- sliding_steps¶
number of rolling steps to take (# of folds)
- model_class¶
the Kats model class
- multi¶
flag to use multiprocessing, the default is True
- confidence_level¶
the confidence level for the prediction interval
- diagnose()[source]¶
Diagnose the linear model fit for SE
Plot the OLS fit: SE ~ Horizon
- Parameters
None –
- Returns
None
- get_eci(steps: int, **kwargs)[source]¶
Get empirical prediction interval
- Parameters
steps – the length of forecasting horizon
- Returns
The dataframe of forecasted values with prediction intervals
- get_lr()[source]¶
Fit linear regression model
Fit linear regression model for std ~ horizon return the fitted model
- Parameters
None –
- Returns
None