what is future covariates? from darts.datasets import AirPassengersDataset from…
- User
User: what is future covariates?
from darts.datasets import AirPassengersDataset from darts.models import KalmanForecaster from darts.utils.timeseries_generation import datetime_attribute_timeseries series = AirPassengersDataset().load()
optionally, use some future covariates; e.g. the value of the month encoded as a sine and cosine series
future_cov = datetime_attribute_timeseries(series, "month", cyclic=True, add_length=6)
increasing the size of the state vector
model = KalmanForecaster(dim_x=12) model.fit(series, future_covariates=future_cov) pred = model.predict(6, future_covariates=future_cov) pred.values() array([[474.40680728], [440.51801726], [461.94512461], [494.42090089], [528.6436328 ], [590.30647185]]) Assistant: In time series forecasting, future covariates (also known as exogenous variables or external regressors) are additional variables that you believe might have an impact on the variable you're trying to predict. These covariates are provided as inputs to the forecasting model alongside the main time series data to potentially improve the model's accuracy.
For the "AirPassengers" dataset and the KalmanForecaster model you are using, you have chosen the "month" as a future covariate, encoded as sine and cosine components. This technique is common when dealing with cyclic or periodic patterns, such as seasonal effects. By encoding the month in this way, you're essentially providing the model with information about the cyclic nature of the data, which might help it make more informed forecasts.
Here's a breakdown of what's happening in your code:
-
Data Loading: You load the AirPassengers time series dataset, which contains monthly passenger numbers for an airline.
-
Covariate Generation: Use the
datetime_attribute_timeseriesutility to create a time series of cyclic covariates corresponding to months, with sine and cosine transformations. These transformations help in capturing the cyclic nature and allow the model to understand the repeating patterns (e.g., seasonality). -
Model Configuration: A
KalmanForecastermodel is initialized with an increased state dimension (dim_x=12). This state vector's dimension influences how much past information the model can incorporate. -
Model Fitting and Prediction: Fit the model to the data while providing both the primary time series and the future covariates. Then, predict future values by using these covariates to make better forecasts.
In summary, future covariates like the cyclic month representation can improve forecast accuracy by incorporating periodic effects into the modeling process. User: can i use future covariate such as weather component like weather? Assistant: Yes, you can use weather-related data as future covariates in your time series forecasting model if you believe they may have an impact on the variable you are trying to predict. This is particularly useful in scenarios where weather conditions can influence the target, such as predicting energy consumption, sales of seasonal products, or agricultural yields.
-
- Assistant
In the context of the
KalmanForecasterin the Darts library,dim_xrefers to the dimensionality of the state vector in the Kalman Filter model. The state vector represents the underlying state of the system being modeled, which the filter estimates and updates as new observations become available.Here's a bit more detail about what
dim_xsignifies:-
State Representation: The state vector is an internal representation of the system's state at each time step. This could include different components, such as level, trend, seasonality, and any other latent factors the model is designed to capture.
-
Flexibility: By setting
dim_x, you can control the complexity and flexibility of the model. A higher dimension allows the model to capture more intricate dynamics in the data, including interactions between different components.
-