darts
darts copied to clipboard
[QUESTION] Croston and add_encoders
Hi,
I cant get add_encoders functionality (for Croston) to work, see below
temporal_cv_lf basically just calls
m = Croston(**params)
m.historical_forecasts(series=series, forecast_horizon=forecast_horizon, last_points_only=False, overlap_end=False, stride=1, retrain=True))
Any help would be appreciated
Hi @sebros-sandvik, Darts' Croston model doesn't support covariates, and can therefore not use the encoders. You can find which models support covariates in the model support table here.
Hi,
Ok just fyi if this needs changing
:
Sorry, my bad. Actually the model support table is not correct. We'll fix that ASAP. Croston method indeed supports future covariates.
Can you provide a minimal reproducible example and the error message that you receive?
Hi @dennisbader ,
of course sir:
import pandas as pd
from darts.models import Croston
from darts import TimeSeries, concatenate
import numpy as np
dates = pd.date_range(start='2019-02-01', end='2023-03-01', freq='MS')
month = dates.month
np.random.seed(1)
noise = np.random.normal(0, 1, len(dates))
sales = month + noise
data = pd.DataFrame({'date': dates, 'sales': sales})
series = TimeSeries.from_dataframe(data, 'date', 'sales')
params1 = {'version': 'tsb', 'alpha_d': 0.7056278684620902, 'alpha_p': 0.12437058458227879}
params2 = {'version': 'tsb', 'alpha_d': 0.7056278684620902, 'alpha_p': 0.12437058458227879,
'add_encoders': {'cyclic': {'future': ['month']}}}
m1 = Croston(**params1)
m2 = Croston(**params2)
pred1 = concatenate(m1.historical_forecasts(series=series,
forecast_horizon=1,
last_points_only=False,
overlap_end=False,
stride=1,
retrain=True))
pred2 = concatenate(m2.historical_forecasts(series=series,
forecast_horizon=1,
last_points_only=False,
overlap_end=False,
stride=1,
retrain=True))
print(pred1 == pred2)
Hi @sebros-sandvik,
After inspecting the implementation of Croston, it seems like the covariates (X
in their API) is only used when using conformal prediction (not yet supported by Darts).
We will revert the changes to the table and update the constructor of this model to remove the add_encoders
argument as it actually does not support future covariates.
Sorry for the confusion and the delay.