Forecaster
UpdateRefitsEvery
Refits periodically when update is called.
Quickstart
python
from sktime.forecasting.stream import UpdateRefitsEvery
estimator = UpdateRefitsEvery(forecaster, refit_interval=0, refit_window_size=None, refit_window_lag=0)Parameters(4)
- forecasteran sktime forecaster
- the forecaster to be refit/updated regularly
- refit_intervaldifference of sktime time indices (int or timedelta), optional
interval that needs to elapse after which the first update defaults to fit default = 0, i.e., always refits, never updates
if index of
yseen infitis integer oryis index-free container type,refit_intervalmust beint, and is interpreted as difference ofintlocationif index of
yseen infitis timestamp, must beintorpd.Timedeltaif
pd.Timedelta, will be interpreted as time since last refit elapsedif int, will be interpreted as number of time stamps seen since last refit
- refit_window_sizedifference of sktime time indices (int or timedelta), optional
- length of the data window to refit to in case update calls fit; default = inf, i.e., refits to entire training data seen so far
- refit_window_lagdifference of sktime indices (int or timedelta), optional
lag of the data window to refit to, w.r.t.
cutoff, in caseupdatecallsfit; default = 0, i.e., refit window ends with and includescutoff
Examples
>>> from sktime.forecasting.trend import TrendForecaster
>>> from sktime.forecasting.stream import UpdateRefitsEvery
>>> from sktime.datasets import load_airline
>>> y = load_airline ()
>>> y0 = y. iloc [: - 20 ]
>>> y1 = y. iloc [- 20: - 10 ]
>>> y2 = y. iloc [- 10:]
>>> forecaster = TrendForecaster ()
>>> forecaster = UpdateRefitsEvery (forecaster, refit_interval = 12)
>>> forecaster. fit (y0, fh = [1, 2, 3 ]) UpdateRefitsEvery(
... )
>>> # predict etc could be called here
>>> # e.g., forecaster.predict()
>>>
>>> # first update, 10 < refit_interval = 12, so calls update
>>> forecaster. update (y1) UpdateRefitsEvery(
... )
>>> # second update, 20 >= refit_interval = 12, so calls fit
>>> forecaster. update (y2) UpdateRefitsEvery(
... )