[BUG] Issue of the class ForecastingHorizon and related functions causing downstream issues with Prophet Ensemble
See original GitHub issueDescribe the bug
Since Prophet needs the index to be in pd.DatetimeIndex
format, it does not work in ensemble mode with other models.
To Reproduce
y = load_airline()
y_train, y_test = temporal_train_test_split(y, test_size=36)
fh = ForecastingHorizon(y_test.index, is_relative=False)
forecaster = EnsembleForecaster([
("autoARIMA", AutoARIMA(sp=12, suppress_warnings=True)),
("autoETS", AutoETS(auto=True, sp=12, n_jobs=-1)),
("fbprophet", Prophet(seasonality_mode="multiplicative", add_country_holidays={"country_name": "US"}))
])
%time forecaster.fit(y_train)
y_pred = forecaster.predict(fh)
Error message is as follows
NotImplementedError: <class 'pandas.core.indexes.period.PeriodIndex'> is not supported. Please use type: <class 'pandas.core.indexes.datetimes.DatetimeIndex'> instead.
Expected behavior
It would be ok to provide a working example of this use case. If it means I have to change data index to pd.DatetimeIndex
for other models, I am ok doing that but I tried it and it gave an error as well
# Convert index to pd.DatetimeIndex
z = y.copy()
z.index = y.index.to_timestamp()
z_train, z_test = temporal_train_test_split(z, test_size=36)
forecaster = EnsembleForecaster([
("autoARIMA", AutoARIMA(sp=12, suppress_warnings=True)),
("autoETS", AutoETS(auto=True, sp=12, n_jobs=-1)),
("fbprophet", Prophet( seasonality_mode="multiplicative", add_country_holidays={"country_name": "US"}))
])
%time forecaster.fit(z_train)
y_pred = forecaster.predict(fh)
Error Message is as follows
sktime\forecasting\base\_fh.py in _check_cutoff(self, cutoff)
388
389 if isinstance(index, pd.PeriodIndex):
--> 390 assert isinstance(cutoff, pd.Period)
391 if isinstance(index, pd.DatetimeIndex):
392 assert isinstance(cutoff, pd.Timestamp)
I tried another variant of the above (changes the arg to the pred function) but got a different error
forecaster = EnsembleForecaster([
("autoARIMA", AutoARIMA(sp=12, suppress_warnings=True)),
("autoETS", AutoETS(auto=True, sp=12, n_jobs=-1)),
("fbprophet", Prophet( seasonality_mode="multiplicative", add_country_holidays={"country_name": "US"}))
])
%time forecaster.fit(z_train)
y_pred = forecaster.predict(fh.to_relative(cutoff=y_train.index[-1]))
sktime\forecasting\base\_fh.py in _check_values(values)
108 # check values does not contain duplicates
109 if len(values) != values.nunique():
--> 110 raise ValueError("`values` must not contain duplicates.")
111
112 # return sorted values
ValueError: `values` must not contain duplicates.
Versions System: python: 3.6.12 |Anaconda, Inc.| (default, Sep 9 2020, 00:29:25) [MSC v.1916 64 bit (AMD64)] executable: C:\Users\Nikhil.conda\envs\sktime_dev\python.exe machine: Windows-10-10.0.18362-SP0
Python dependencies: pip: 20.3.3 setuptools: 51.0.0.post20201207 sklearn: 0.24.0 sktime: 0.5.0 statsmodels: 0.12.1 numpy: 1.19.4 scipy: 1.5.4 Cython: 0.29.17 pandas: 1.1.5 matplotlib: 3.3.3 joblib: 1.0.0 numba: 0.52.0 pmdarima: 1.8.0 tsfresh: 0.17.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
@ngupta23 I was playing a bit around and was able to recreate this. This issues do not come from
sktime.Prophet
. Could you pls rename the this issue? It seems to be solely an issue of the classForecastingHorizon
and related functions.Closed in favour or #534