question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Issue of the class ForecastingHorizon and related functions causing downstream issues with Prophet Ensemble

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
aiwaltercommented, Dec 24, 2020

@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 class ForecastingHorizon and related functions.

0reactions
mloningcommented, Dec 28, 2020

Closed in favour or #534

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Issue of the class ForecastingHorizon and related ...
[BUG] Issue of the class ForecastingHorizon and related functions causing downstream issues with Prophet Ensemble #561.
Read more >
Diagnostics | Prophet - Meta Open Source
Prophet includes functionality for time series cross validation to measure forecast error using historical data. This is done by selecting cutoff points in ......
Read more >
Prophet — sktime documentation
class Prophet (freq=None, add_seasonality=None, add_country_holidays=None, growth='linear', changepoints=None, ... Forecasting horizon that was passed.
Read more >
Forecasting: theory and practice - ScienceDirect.com
Forecasting procedures are best when they relate to a problem to be solved in practice. The theory can then be developed by understanding...
Read more >
theory and practice - International Journal of Forecasting
Forecasting has always been at the forefront of decision making and planning. The uncertainty that surrounds the future is both exciting and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found