sktime: [BUG] Cannot chain STLBootstrapTransformer, Imputer and BaggingForecaster in one forecast pipeline

Describe the bug First of all, thanks a lot for putting this package together. It is very good and helpful.

I want to use BaggingForecaster with STLBootstrapTransformer to create boostrapped time series and then use ARIMA as forecaster.

The issue I ran into is that sometimes boostrapped time series contains NaN. ARIMA does not work with input data that has missing values.

My way of getting around it is to add Impute, i.e. use the nearest number to impute the missing values.

My question is how should I include impute into the forecasting pipeline? I tried ForecastingPipeline, but I could not feed the imputed and boostrapped time series into the bagging forecaster.

Example code is below. I use NaiveForecaster for simplicity. To Reproduce

<Paste your code here>

from sktime.transformations.series.impute import Imputer

from sktime.forecasting.naive import NaiveForecaster

from sktime.datasets import load_airline

y = load_airline()

bagging =STLBootstrapTransformer(4, sp = 4)  

bagging_forecaster = BaggingForecaster(forecaster=NaiveForecaster(strategy = 'last'))

forecaster  = ForecastingPipeline(

    steps=[

        ("a",bagging),

        ("b", Imputer(method = 'nearest')),

        ("forecaster", bagging_forecaster),

    ]

)

 

forecaster.fit(y=y, fh=[1,2,3])

forecaster.predict()

**Expected behavior**
When you run above code, you can check forecaster.get_fitted_params(), you will see that bagging forecaster used default STLBoostrapTransformer (n_series = 10). 

Additional context

Versions

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Comments: 22 (3 by maintainers)

Most upvoted comments

No worries. I will test it out today and report it back.

Perhaps the key question I should have started with is STLBOOSTRAPTRANSFORMER produced NaN values. I have a small time series (24 data points quarterly data). I wonder if that’s the reason. I will add data and code to the thread here later.