automl / auto-sklearn

Automated Machine Learning with scikit-learn
https://automl.github.io/auto-sklearn
BSD 3-Clause "New" or "Revised" License
7.58k stars 1.28k forks source link

[Question] TimeSeriesSplit to use auto-sklearn for time series doesn't work #1709

Open samuelverdaasdonk opened 10 months ago

samuelverdaasdonk commented 10 months ago

I want to use Auto-Sklearn for time series prediction. From what I understand from issue #501 , is that one should use resampling_strategy = sklearn.model_selection.TimeSeriesSplit in the AutoSklearnClassifier(). However, I have to use the AutoSklearnRegresor(). When I try to pass the TimeSeriesSplit argumument into this I get this error: ValueError: Illegal resampling strategy: <class 'sklearn.model_selection._split.TimeSeriesSplit'>.

For reference, I use this simple code (part of a rolling window):

X_train = X[:17835]
y_train = y[:17835]

X_test = X[17835:19628]
y_test = y[17835:19628]

automl = AutoSklearnRegressor(resampling_strategy=sklearn.model_selection.TimeSeriesSplit)
automl.fit(X_train, y_train)
preds = automl.predict(X_test)

results in:

[ERROR] [2023-12-06 12:20:54,725:Client-AutoML(1):81694fc2-9429-11ee-9d15-3f0b37f0904e] Illegal resampling strategy: <class 'sklearn.model_selection._split.TimeSeriesSplit'>
Traceback (most recent call last):
  File "/home/sverdaasdonk/Ubuntu/env_with_python3.7/lib/python3.7/site-packages/autosklearn/automl.py", line 694, in fit
    task=self._task,
  File "/home/sverdaasdonk/Ubuntu/env_with_python3.7/lib/python3.7/site-packages/autosklearn/automl.py", line 1112, in _check_resampling_strategy
    "Illegal resampling strategy: %s" % self._resampling_strategy
ValueError: Illegal resampling strategy: <class 'sklearn.model_selection._split.TimeSeriesSplit'>

Does anyone know if it is possible to use TimeSeriesSplit for AutoSklearnRegressor(), and/or to fix this error? Thanks in advance! (I use Ubuntu and Auto-Sklearn 0.15.0)