microsoft / FLAML

A fast library for AutoML and tuning. Join our Discord: https://discord.gg/Cppx2vSPVP.
https://microsoft.github.io/FLAML/
MIT License
3.84k stars 505 forks source link

When use ts_forecast with lgb, 2 more lags, results looks like just shift of series itself. #1001

Open xiaoyaoyang opened 1 year ago

xiaoyaoyang commented 1 year ago
  1. How exactly ts_forecast + lgb/ xgboost works? I looked it up in code seems it leverage https://hcrystalball.readthedocs.io/en/latest/, is there a documentation that introduce exactly what each parameters does and how those thing work together?
  2. I am also trying to understand what 1) Optimize_for_horizon 2) lags 3) retrain_full means. For example, retrain_full I would expect the model use full train+test dataset, with tuned parameters and train the model at the end, is that the case? (Sorry if it's already in documentation, I did not find it)
  3. I am seeing some strange behavior when lags>1 with loss MAPE, specifically the predicted series would looks just like a shift of original series, chart show below.
image
ZmeiGorynych commented 1 year ago

hcrystalball just collects lagged values of the series and feeds them as features to a sklearn model, treating the next value as the target. lags is just the number of lags it takes, and if you choose optimize_for_horizon=True, it fits not just one model, but a series of models for predicting different number of days ahead.

retrain_full=True (recommended) means that initially you hold back the final chunk of the train set to use as validation for hyperparameter tuning, but once you've chosen a model and hyperparameter set, you retrain using those on the whole training set. This is especially important as many time series models must be trained on all in-sample data to predict out of sample.

The behavior you're seeing is just that the fit didn't converge that well, namely the best solution it's been able to find is very close to just using the value N periods ago as the forecast for the value right now.

Why do you restrict yourself to lgb/xboost solvers anyway? As often as not, I find classics like SARIMA-X to perform quite well, or perhaps the recently added Holt-Winters.

Finally, the time series in the plot is just quite hard to predict. It seems to be essentially noise with occasional random spikes - I'd be surprised if any method was particularly good at forecasting that.

Sandy4321 commented 1 year ago

@ZmeiGorynych Why do you restrict yourself to lgb/xboost solvers anyway? As often as not, I find classics like SARIMA-X to perform quite well, or perhaps the recently added Holt-Winters may you share code example please ?

ZmeiGorynych commented 1 year ago

Just give the argument estimator_list=['arima', 'sarimax', 'holt-winters'] to the fit() method

xiaoyaoyang commented 1 year ago

thanks for reply!! the reason why I choose tree model is I need interpretation and want to use SHAP afterward.