Derive ForecastingHorizon from DatetimeIndex in predict method
See original GitHub issueIs your feature request related to a problem? Please describe.
Basically just a simplification request: converting from DatetimeIndex to ForecastingHorizon seems to me like a step that the BaseForecaster
should be able to handle by itself. So instead of:
model = NaiveForecaster()
model.fit(train_data)
fh = ForecastingHorizon(test_data.index, is_relative=False)
forecast_data = model.predict(fh)
I would suggest users should be able to do:
model = NaiveForecaster()
model.fit(train_data)
forecast_data = model.predict(test_data.index)
which would be very elegant imo. It also removes the need to import ForecastingHorizon
, which shortens user code and—and here’s my selfish reason—possibly avoids adding sktime as an explicit dependency in libraries that want to be sktime compatible but do not want to depend on it.
Describe the solution you’d like
Perhaps the BaseForecaster.predict
method can check whether its fh
argument is a DatetimeIndex instance and run the necessary conversion itself?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
I quickly mocked sth up, @Flix6x, in #1169 - it appears the
ForecastingHorizon
constructor complains when getting apd.DatetimeIndex
instead of doing what I’d think is the obvious thing (from user perspective).The tests still run for some time and I have to sign off now, but feel free to have a look (and help me debugging in case they break 😃 )
Well, thanks for bringing it up, @Flix6x! This behaviour was not on my mental map.