winedarksea / AutoTS

Automated Time Series Forecasting
MIT License
1.11k stars 100 forks source link

Cant' get high VARMAX orders from AutoTS #77

Closed Abdelgha-4 closed 3 years ago

Abdelgha-4 commented 3 years ago

No matter the value that I set in max_generations arg, the orders of VARMAX that I get are always between 0 and 2. Is there is any way to make AutoTS tries higher orders for VARIMAX models ? I tried various parameters with AutoTS, here is an example of how I create a model and fit it.

model = AutoTS(
    forecast_length=9,
    frequency='M',
    prediction_interval=0.9,
    model_list=["VARMAX"],
    ensemble="all",
    max_generations=100,
    num_validations=2,
    validation_method="backwards",
    random_seed=7,
    models_to_validate = 0.2,
    transformer_list="all",
    transformer_max_depth=8
)
# VARMA_train_data is a wide data set of 6 columns and 54 monthly observasions
model.fit(VARMA_train_data)
winedarksea commented 3 years ago

Yep, it is hard-coded that way.

Why? Because higher orders get really slow, and because I didn't notice any series actually benefiting from that slowdown (vs using faster models of other kinds that were also more accurate).

You can of course do it manually with statsmodels VARMAX directly, or even from the VARMAX class here directly.

I can add higher orders in (with a low probability of choice) if you think it would be useful. I'd probably throw in a value of 7. Are there any orders in particular you think would be useful?

@Abdelgha-4

Abdelgha-4 commented 3 years ago

Ok thank you ! One question : doesn't the random choice of the orders every time means that the same orders can be repeated in some models ? and about the orders I don't know, but I which it could be possible to set the max lags manually.

winedarksea commented 3 years ago

To answer the first part of your question is a bit of a long explanation. The random choice is part of the genetic algorithm, which also combines previous models (a random article I grabbed on that from google, here). Yes, the model orders can be repeated, but they'll be paired with new Transformations - true duplicates are removed and not run.

I've thrown a 7th order in as an option (with low probability) that will be in the next version 0.3.3 which will be out in... a week maybe?

Here's the hack for getting in parameter values that aren't normally allowed:

  1. Run AutoTS and export a template (see extended tutorial for that)
  2. Open the template in a text editor or Excel and manually change the VARMAX values to whatever you want (in this case, it is passed through to Statsmodels, so anything that will handle.
  3. Run AutoTS again, this time importing the template (see tutorial) before running .fit()
  4. There is no guarantee it will choose the model with higher orders - choices are made based on validation accuracy, but it will at least run it, and if it does well, it will be incorporated into new models (that's how the genetic algorithms work).
Abdelgha-4 commented 3 years ago

Ok, Thank you for the explanation and the smart hack I'll work with that until the next version !