google-research / timesfm

TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.
https://research.google/blog/a-decoder-only-foundation-model-for-time-series-forecasting/
Apache License 2.0
3.69k stars 319 forks source link

error when calculating the MSE and MAS between ols_forecast and true value. #116

Open JieNi4 opened 2 months ago

JieNi4 commented 2 months ago

Normalisation of the output of the Xreg model is used in timesfm.py if we use covariance_forecast. But the code only renormalise the output of timesfm with covariance. And the output of Xreg model is very small. So it's meaningless to compare with different models.

we should add this code 'xregs = _renormalize(xregs, per_instance_stats))' in timesfm.py file (about 745 raws).

siriuz42 commented 2 months ago

The xreg output is mostly FYI. My intuition is that renormalizing xreg output makes little sense if we call TimesFM forecast first and use xreg to fit the residuals.

Do you have a specific usecase in mind?

JieNi4 commented 2 months ago

If we use xregmode = 'xreg + timesfm', then algorithm will first use xreg based on 'cov' predict the target y'. and then calculating the residuals between y' and the true label y : d. Then TimesFM will according to this delta predict the future residuals d' for the xreg model. Finally, Xreg will based on the new cov input predict the future target y''. The result finally is y_pred = y'' + d'. It's the basic function. In this method, it seems like xreg model will preform the more important role than timesfm model. And another question, shall we use other regression model like SVR, Boost ?

siriuz42 commented 2 months ago

You understanding is correct. Other regression models also work and can be implemented in a similar fashion. Linear + ridge are provided here since they have closed form solutions which have relatively minimal (but still significant) impacts on the e2e inference latency.

JieNi4 commented 2 months ago

Thank you for your reply. It's a nice model. Hope a new version will be published.