FallbackForecaster
Forecaster that sequentially tries a list of forecasting models.
Attempts to fit the provided forecasters in the order they are given. If a forecaster fails during fitting or prediction, it proceeds to the next one. This class is useful in scenarios where the reliability of individual forecasting models may be in question, and a fallback mechanism is desired.
Schnellstart
from sktime.forecasting.compose import FallbackForecaster
estimator = FallbackForecaster(forecasters, verbose=False, nan_predict_policy='ignore')Parameter(3)
- forecasterslist of forecasters, or
list of tuples (str, estimator) of sktime forecasters Forecasters to be tried sequentially. These are “blueprint” transformers resp forecasters, forecaster states do not change when
fitis called- verbosebool, default=False
- If True, raises warnings when a forecaster fails to fit or predict.
- nan_predict_policy: str, default=’ignore’
Determines the action to take if NaN values are found in the predictions. Available options:
“ignore”
“raise”
“warn”
When set to ‘raise’, this policy treats NaN predictions as errors, prompting the FallbackForecaster to sequentially try the next forecaster in the queue. This process continues until a NaN-free prediction is obtained or all forecasters have been attempted, in which case the operation fails. Conversely, the ‘warn’ option alerts to the presence of NaNs in predictions with a warning, but does not alter the forecasting sequence. The default ‘ignore’ mode takes no action, permitting the forecasting process to proceed uninterrupted and without issuing warnings or errors, regardless of NaN occurrences in predictions.
Beispiele
>>> from sktime.forecasting.naive import NaiveForecaster
>>> from sktime.forecasting.compose import FallbackForecaster
>>> from sktime.forecasting.compose import EnsembleForecaster
>>> from sktime.forecasting.trend import PolynomialTrendForecaster
>>> from sktime.datasets import load_airline
>>> y = load_airline ()
>>> # first fit polynomial trend, if fails make naive forecast
>>> forecasters = [
... ("poly", PolynomialTrendForecaster ()),
... ("naive", NaiveForecaster ())
... ]
>>> forecaster = FallbackForecaster (forecasters = forecasters)
>>> forecaster. fit (y = y, fh = [1, 2, 3 ]) FallbackForecaster(
... )
>>> y_pred = forecaster. predict ()