Nixtla / neuralforecast

Scalable and user friendly neural :brain: forecasting algorithms.
https://nixtlaverse.nixtla.io/neuralforecast
Apache License 2.0
2.9k stars 332 forks source link

[Bug] Interpretable NBEATSx is incompatible with horizon=1 #609

Closed kdgutier closed 1 year ago

kdgutier commented 1 year ago

By the definition of the basis projections, when the h=1 the basis are not correctly defined. It is convenient to raise an exception on the interpretable NBEATSx model in the presence of h=1.

The error output of such a model is the following:

RuntimeError: einsum(): subscript p has size 2 for operand 1 which does not broadcast with previously seen size 0
brdeleeuw commented 1 year ago

@kdgutier and @cchallu FYI this same error occurs for the "regular" (non-Auto) NBEATS model.

kdgutier commented 1 year ago

Hey @brdeleeuw,

Thanks for reporting the bug. We added a raise.Exception protection for the corner cases of h=1 with seasonality harmonics and polynomial trends.

In the AutoNBEATS current version, we use a generic config search space that may break on h=1. To solve this problem, you would need to overwrite the config's stack_types parameter:

  default_config = {
      "input_size_multiplier": [1, 2, 3, 4, 5],
      "h": None,
      "stack_types" : tune.choice(['identity', 'identity', 'identity']),
      "learning_rate": tune.loguniform(1e-4, 1e-1),
      "scaler_type": tune.choice([None, "robust", "standard"]),
      "max_steps": tune.choice([500, 1000]),
      "batch_size": tune.choice([32, 64, 128, 256]),
      "windows_batch_size": tune.choice([128, 256, 512, 1024]),
      "loss": None,
      "random_seed": tune.randint(1, 20),
  }