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

[BUG] Inconsistent minimum time series length behaviour #2264

Open
elbal opened this issue Mar 4, 2024 · 1 comment · May be fixed by #2353
Open

[BUG] Inconsistent minimum time series length behaviour #2264

elbal opened this issue Mar 4, 2024 · 1 comment · May be fixed by #2353
Labels
bug Something isn't working improvement New feature or improvement

Comments

@elbal
Copy link

elbal commented Mar 4, 2024

Describe the bug
Given an ARIMA model using fit() or historical_forecasts() with a time series with less than 30 elements results in the error:
Train series only contains N elements but ARIMA(p=0) model requires at least 30 entries

This is inconsistent with how AutoARIMA works, AutoARIMA has no check for the minimum time series length and works (without issues?) for time series with less than 30 entries.
The behaviour is also inconsistent with statsmodel ARIMA that Darts is wrapping as in statsmodel ARIMA has no minimum time series lenght.

To Reproduce

import darts
import pandas as pd
from statsmodels.tsa.arima.model import ARIMA as ARIMA_sm
from darts.models.forecasting.arima import ARIMA as ARIMA_darts
from darts.models.forecasting.auto_arima import AutoARIMA as AutoARIMA_darts

df = pd.DataFrame({"demand": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]})
ts = darts.TimeSeries.from_dataframe(df)

#### statsmodel ARIMA test
arima_sm = ARIMA_sm(endog=df["demand"])
arima_sm = arima_sm.fit()
arima_sm.predict()

#### Darts AutoARIMA test - fit() - no errors
auto_arima_darts = AutoARIMA_darts(seasonal=False, stationary=False)
auto_arima_darts.fit(ts)

#### Darts AutoARIMA test - historical_forecasts() - no errors
forecast = auto_arima_darts.historical_forecasts(ts)
forecast.pd_dataframe().head(None)

#### DartsARIMA test - fit() - error
arima_darts = ARIMA_darts(p=0, d=1, q=0)
arima_darts = arima_darts.fit(ts)

#### DartsARIMA test - historical_forecasts() - error
arima_darts = ARIMA_darts(p=0, d=1, q=0)
arima_darts = arima_darts.historical_forecasts(ts)

Expected behavior
I am not sure if there should be a minimim series lenght as there is non for the wrapper statsmodel ARIMA.
If a minimum series lenght sould exist it should be consistent accross the board.

System (please complete the following information):

  • Python version: 3.10.7
  • darts version 0.27.2

Additional context
None.

@elbal elbal added bug Something isn't working triage Issue waiting for triaging labels Mar 4, 2024
@madtoinou
Copy link
Collaborator

madtoinou commented Mar 4, 2024

Hi @elbal,

First of all, thank you for reporting this inconsistency and the detailed code snippet.

I am not exactly sure why the length requirements are as they are in these two classes (old undocumented code, min_train_series_length returns 10 for AutoARIMA and 30 for ARIMA), I am going to investigate. However, since ARIMA and AutoARIMA don't come from the same libraries, the additional logic in AutoARIMA might come with constraints and Darts can't really be responsible for making it consistent. I'll keep you updated.

On another stream, an inconsistency between min_train_series_length and min_train_samples was noticed, and I am already working on it. Fixing both at the same time sounds doable.

EDIT: Went down the blame hole, found this comment. The value of 30 (as well as 10) seems arbitrary, I can remove them and rely on the default of 3 defined in ForecastingModel; user will be responsible for knowing that using such a limited number of samples will result in terrible forecasts.

@madtoinou madtoinou added improvement New feature or improvement and removed triage Issue waiting for triaging labels Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working improvement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants