Last active
October 23, 2021 12:10
-
-
Save ngupta23/e339c7dc773488da9bf6df294dbd9376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Step 1: Load data and simulate missing value ---- | |
import numpy as np | |
from sktime.datasets import load_airline | |
y = load_airline() | |
y[2] = np.nan | |
#### Step 2: Create pipeline with preprocessing ---- | |
from sktime.forecasting.compose import ForecastingPipeline | |
from sktime.transformations.series.impute import Imputer | |
from sktime.transformations.series.boxcox import LogTransformer | |
from sktime.forecasting.compose import TransformedTargetForecaster | |
from sktime.transformations.series.detrend import Deseasonalizer | |
from sktime.forecasting.arima import ARIMA | |
forecaster = TransformedTargetForecaster( | |
[ | |
("deseasonalize", Deseasonalizer(model="multiplicative", sp=12)), | |
("model", ARIMA()), | |
] | |
) | |
pipe = ForecastingPipeline( | |
[ | |
("impute", Imputer()), | |
("log", LogTransformer()), | |
("forecast", forecaster) | |
] | |
) | |
#### Step 3: Train and Predict ---- | |
pipe.fit(y, X=None, fh=np.arange(1,13)) | |
pipe.predict(X=None) | |
""" | |
--------------------------------------------------------------------------- | |
ValueError Traceback (most recent call last) | |
~\AppData\Local\Temp/ipykernel_9484/2011357560.py in <module> | |
28 | |
29 #### Train and Predict | |
---> 30 pipe.fit(y, X=None, fh=np.arange(1,13)) | |
31 pipe.predict(X=None) | |
~\.conda\envs\pycaret_dev_sktime_0p7\lib\site-packages\sktime\forecasting\base\_base.py in fit(self, y, X, fh) | |
178 ##################################################### | |
179 | |
--> 180 self._fit(y=y_inner, X=X_inner, fh=fh) | |
181 | |
182 # this should happen last | |
~\.conda\envs\pycaret_dev_sktime_0p7\lib\site-packages\sktime\forecasting\compose\_pipeline.py in _fit(self, y, X, fh) | |
207 name, forecaster = self.steps[-1] | |
208 f = clone(forecaster) | |
--> 209 f.fit(y, X, fh) | |
210 self.steps_[-1] = (name, f) | |
211 | |
~\.conda\envs\pycaret_dev_sktime_0p7\lib\site-packages\sktime\forecasting\base\_base.py in fit(self, y, X, fh) | |
178 ##################################################### | |
179 | |
--> 180 self._fit(y=y_inner, X=X_inner, fh=fh) | |
181 | |
182 # this should happen last | |
~\.conda\envs\pycaret_dev_sktime_0p7\lib\site-packages\sktime\forecasting\compose\_pipeline.py in _fit(self, y, X, fh) | |
347 for step_idx, name, transformer in self._iter_transformers(): | |
348 t = clone(transformer) | |
--> 349 y = t.fit_transform(y, X) | |
350 self.steps_[step_idx] = (name, t) | |
351 | |
~\.conda\envs\pycaret_dev_sktime_0p7\lib\site-packages\sktime\transformations\base.py in fit_transform(self, Z, X) | |
86 if X is None: | |
87 # Fit method of arity 1 (unsupervised transformation) | |
---> 88 return self.fit(Z).transform(Z) | |
89 else: | |
90 # Fit method of arity 2 (supervised transformation) | |
~\.conda\envs\pycaret_dev_sktime_0p7\lib\site-packages\sktime\transformations\series\detrend\_deseasonalize.py in fit(self, Z, X) | |
119 filt=None, | |
120 two_sided=True, | |
--> 121 extrapolate_trend=0, | |
122 ).seasonal.iloc[:sp] | |
123 | |
~\.conda\envs\pycaret_dev_sktime_0p7\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs) | |
205 else: | |
206 kwargs[new_arg_name] = new_arg_value | |
--> 207 return func(*args, **kwargs) | |
208 | |
209 return cast(F, wrapper) | |
~\.conda\envs\pycaret_dev_sktime_0p7\lib\site-packages\statsmodels\tsa\seasonal.py in seasonal_decompose(x, model, filt, period, two_sided, extrapolate_trend) | |
130 | |
131 if not np.all(np.isfinite(x)): | |
--> 132 raise ValueError("This function does not handle missing values") | |
133 if model.startswith('m'): | |
134 if np.any(x <= 0): | |
ValueError: This function does not handle missing values | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment