You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A clear and concise description of what the bug is.
NaiveEnsembleModel.historical_forecasts() does not handle multiple sets of past_covariates
To Reproduce
fromdarts.modelsimportLinearRegressionModel, NaiveEnsembleModelfromdarts.datasetsimportAirPassengersDataset, MonthlyMilkDatasetfromdarts.utils.timeseries_generationimportdatetime_attribute_timeseries# Load two different time series datasetsts_air=AirPassengersDataset().load() # Example: Air passengers datasetts_milk=MonthlyMilkDataset().load() # Example: Milk production dataset# Expand the datasets to be multivariate by adding additional features# For ts_air, add a datetime attribute (e.g., month as a numeric feature)ts_air_multivariate=ts_air.stack(
datetime_attribute_timeseries(ts_air.time_index, attribute="month", one_hot=False)
)
# For ts_milk, add a datetime attribute (e.g., year as a numeric feature)ts_milk_multivariate=ts_milk.stack(
datetime_attribute_timeseries(ts_milk.time_index, attribute="year", one_hot=False)
)
# Define two Linear Regression models with multivariate past covariates# Use lags_past_covariates as dictionaries with variable names and lag valuesmodel1=LinearRegressionModel(
lags=12,
lags_past_covariates={"#Passengers": [-1], "month": [-1, -2, -3]} # Use "month" from ts_air_multivariate
)
model2=LinearRegressionModel(
lags=6,
lags_past_covariates={"Pounds per cow": [-1, -2], "year": [-1]} # Use "milk_production" and "year" from ts_milk_multivariate
)
# Create a NaiveEnsembleModel with the two modelsensemble=NaiveEnsembleModel(forecasting_models=[model1, model2])
# Generate historical forecasts using the ensemble modelbacktest=ensemble.historical_forecasts(
series=ts_air,
past_covariates=[ts_air_multivariate, ts_milk_multivariate], # Provide both sets of multivariate covariatesstart=0.6,
forecast_horizon=3
)
ERROR:darts.models.forecasting.regression_model:ValueError: The `lags_past_covariates` dictionary specifies lags for components that are not present in the series : ['Pounds per cow', 'year']. They must be removed to avoid any ambiguity.
ValueError: The `lags_past_covariates` dictionary specifies lags for components that are not present in the series : ['Pounds per cow', 'year']. They must be removed to avoid any ambiguity.
File <command-7831122302366366>, line 33
30 ensemble = NaiveEnsembleModel(forecasting_models=[model1, model2])
32 # Generate historical forecasts using the ensemble model
---> 33 backtest = ensemble.historical_forecasts(
34 series=ts_air,
35 past_covariates=[ts_air_multivariate, ts_milk_multivariate], # Provide both sets of multivariate covariates
36 start=0.6, # Start forecasting after 60% of the series
37 forecast_horizon=3 # Forecast horizon of 3 steps
38 )
Expected behavior
Given an ensembled model that takes different sets of covariates and the goal of running .historical_forecasts(), the argument past_covariates should be able to distinguish which covariate timeseries belongs to which model
System (please complete the following information):
Python version: Python 3.11.0rc1
darts version 0.32.0
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
The EnsembleModels in Darts pass all the series to all the models, i.e. the forecasting models have access to exactly the same information in order to generate the forecasts. In your use-case, since you use component-wise lags, the training/prediction data cannot be generated for the components that are not defined in the model.
The way you call historical_forecasts is not supported by Darts; the number of covariates should be identical to the number of series to predict (one for each), it's not intended to be dispatched across models.
Describe the bug
A clear and concise description of what the bug is.
NaiveEnsembleModel.historical_forecasts() does not handle multiple sets of past_covariates
To Reproduce
Expected behavior
Given an ensembled model that takes different sets of covariates and the goal of running
.historical_forecasts()
, the argument past_covariates should be able to distinguish which covariate timeseries belongs to which modelSystem (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: