MCRecursiveProbaReductionForecaster
Monte Carlo Recursive reduction forecaster with probabilistic prediction.
Implements recursive reduction with ancestral sampling for multi-step ahead probabilistic forecasting. Uses Monte Carlo sampling to generate multiple forecast trajectories, where each step is sampled from the predicted distribution conditioned on previously sampled values.
This approach is inspired by DeepAR’s ancestral sampling strategy, adapted for use with any tabular probabilistic regressor from skpro.
Algorithm details:
In fit, given endogenous time series y and possibly exogenous X:
fits estimator to feature-label pairs for one-step-ahead prediction: features = y(t), y(t-1), …, y(t-window_length+1), if provided: X(t+1); labels = y(t+1), ranging over all t where the above have been observed
In predict_proba, given possibly exogenous X, at cutoff time c:
Generate
n_samplesMonte Carlo trajectories using ancestral samplingFor each trajectory and each horizon step
h:Get probabilistic prediction from estimator using lagged features
Sample one value from the predicted distribution
Use this sampled value as input for the next step
Construct empirical distribution from the
n_samplestrajectories
In predict, returns the mean of the empirical distribution from MC samples.
Schnellstart
from sktime.forecasting.compose import MCRecursiveProbaReductionForecaster
estimator = MCRecursiveProbaReductionForecaster(estimator, window_length=10, n_samples=100, impute_method='bfill', pooling='local', random_state=None)Parameter(6)
- estimatorskpro probabilistic regressor
Tabular probabilistic regression algorithm used in reduction. Must support
predict_probamethod returning a distribution object.- window_lengthint, optional, default=10
- Window length used in the reduction algorithm (number of lags).
- n_samplesint, optional, default=100
- Number of Monte Carlo sample trajectories to generate. Higher values give more accurate distribution estimates but slower inference.
- impute_methodstr, None, or sktime transformation, optional
Imputation method to use for missing values in the lagged data. default=”bfill” if str, admissible strings are of
Imputer.methodparameter. if sktime transformer, this transformer is applied to the lagged data. if None, no imputation is done.- poolingstr, one of [“local”, “global”, “panel”], optional, default=”local”
- Level on which data are pooled to fit the supervised regression model. “local” = unit/instance level, one reduced model per lowest hierarchy level “global” = top level, one reduced model overall, on pooled data “panel” = second lowest level, one reduced model per panel level (-2)
- random_stateint, RandomState instance or None, optional, default=None
- Controls the randomness of the Monte Carlo sampling.
Beispiele
>>> from sklearn.linear_model import LinearRegression
>>> from skpro.regression.residual import ResidualDouble
>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.compose import MCRecursiveProbaReductionForecaster
>>>
>>> y = load_airline ()
>>>
>>> base_estimator = LinearRegression ()
>>> estimator = ResidualDouble (base_estimator)
>>> forecaster = MCRecursiveProbaReductionForecaster (estimator)
>>>
>>> forecaster. fit (y) MCRecursiveProbaReductionForecaster(
... )
>>> y_pred_dist = forecaster. predict_proba (fh = range (1, 13))
>>> len (y_pred_dist. mean ()) == 12 True