Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forecasting with covariate variables #224

Open
sebassaras02 opened this issue Jan 21, 2025 · 2 comments
Open

Forecasting with covariate variables #224

sebassaras02 opened this issue Jan 21, 2025 · 2 comments

Comments

@sebassaras02
Copy link

Hey,

I've running some models with TSMixer. However, these models were univariate forecasting.

Right now, I want to apply the forecast_with_covariates. Unfortunately, this function is giving to me many mistakes. I've been trying to access to the documentation and the helper docs in python, but this is not as helpful as I want.

To be specific, I have a dataframe with my target variable and a covariate variable. This dataframe has three items to forecast, so I created a nested list. In each sublist, I have 5 values for each item. While for the covariate, I have 6 values for each sublist. I want to forecast, one point ahead. I understood, that I need to pass these additional point in the covariate list. So I have something like this.

`
inputs = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]
exog = [[11, 12, 13, 14, 15, 16], [11, 12, 13, 14, 15, 16],[11, 12, 13, 14, 15, 16]]

model = timesfm.Timesfm(
hparams=timesfm.TimesFmHparams(
backend="cpu",
per_core_batch_size=32,
horizon_len=1
),
checkpoint=timesfm.TimesFmCheckpoint(
hugginface_repo_id="google/timesfm-1.0-200m-pytorch")
)

forecast, _ = model.forecast_with_covariates(
inputs = inputs,
dynamic_numerical_covariates={"exog": exog},
freq=[0]*len(inputs[0]),
xreg_mode="timesfm + xreg",
ridge=0.0,
force_on_cpu=False,
normalize_xreg_target_per_input=True,
)
`

My mistake says:
ValueError: operands could not be broadcast together with shapes (5,) (0,)

Does anyone can explain to me how to use this option of the model? Also, what does it really mean the freq argument?

@siriuz42
Copy link
Collaborator

Can you try xreg_mode="xreg + timesfm" first?

@sebassaras02
Copy link
Author

@siriuz42 I don't understand why, but now the model was able to run. I mean, I changed from "timesfm + xreg" into "x_reg + timesfm". Can you explain this to me, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants