Nixtla / mlforecast

Scalable machine 🤖 learning for time series forecasting.
https://nixtlaverse.nixtla.io/mlforecast
Apache License 2.0
789 stars 74 forks source link

All series are too short for the cross validation settings #343

Closed matsuobasho closed 1 month ago

matsuobasho commented 1 month ago

What happened + What you expected to happen

I get a ValueError: All series are too short for the cross validation settings, at least 4 samples are required. when trying to run cross_validation

I only specify 1 window and predicting just for 1 next period. Am I missing something about the functionality of cross_validation?

Versions / Dependencies

mlforecast 0.12.1 pandas 2.2.2

Reproduction script


from mlforecast import MLForecast
import numpy as np
import pandas as pd

fcst = MLForecast(
    models=lgb.LGBMRegressor(n_jobs=1, random_state=0, verbosity=-1),
    freq='15m',
    lags=[1],   # last 2 hours
    date_features=['hour', 'dayofweek', 'month'],
)

df = pd.DataFrame({'ds': pd.date_range('2017-01-11 10:00:00', '2017-03-01 11:00:00', freq='15min')})
df['y'] = np.random.normal(450, 300, df.shape[0])
df['unique_id'] = 'series1'
df['exog1'] = np.random.normal(250, 20, df.shape[0])
df['exog2'] = np.random.normal(27, 20, df.shape[0])

crossvalidation_df = fcst.cross_validation(
    df=df,
    h=1,
    n_windows=1,
)

Issue Severity

Medium: It is a significant difficulty but I can work around it.