Fix log_training_metric causing IndexError for time series models#1469
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug where setting log_training_metric=True causes failures for time series forecasting models (arima, sarimax, holt-winters). The root cause was that when logging training metrics, FLAML attempted to call predict() on the training data (X_train), which fails for time series models because they expect a TimeSeriesDataset with properly configured test_data for prediction.
Changes:
- Added conditional logic to skip training metric computation for TimeSeriesDataset objects when
log_training_metric=True - Added a new test to verify that time series models work correctly with
log_training_metric=True
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| flaml/automl/ml.py | Added check to skip training metric computation when X_train is a TimeSeriesDataset, preventing the predict() call that would fail for time series models |
| test/automl/test_forecast.py | Added test function to validate that arima, sarimax, and holt-winters models work with log_training_metric=True |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot
AI
changed the title
[WIP] Fix bug in time series model logging
Fix log_training_metric causing IndexError for time series models
Jan 10, 2026
8d53675 to
566972a
Compare
thinkall
approved these changes
Jan 10, 2026
jianglibigdata
approved these changes
Jan 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #1464
Time series models (ARIMA, SARIMAX, Holt-Winters) fail with IndexError when
log_training_metric=Truebecause_eval_estimator()attempts to compute training predictions onTimeSeriesDatasetobjects, which expecttest_datafor prediction but receive training data with empty/unset test splits.Changes
flaml/automl/ml.py
TimeSeriesDatasetinstances in_eval_estimator()test/automl/test_forecast.py
test_log_training_metric_ts_models()validating all three affected models withlog_training_metric=TrueExample
Original prompt
This section details on the original issue you should resolve
<issue_title>[Bug]: Forecasting: log_training_metric causes arima, sarimax, holt-winters to fail when set to true.</issue_title>
<issue_description>### Describe the bug
The key findings are:
Individual TS estimators (arima, sarimax, holt-winters) FAIL with log_training_metric=True
ML estimators (xgboost, lgbm, catboost) PASS
When log_training_metric is NOT set, arima PASSES (see the holdout split test)
ROOT CAUSE HYPOTHESIS:
log_training_metric=Truecauses FLAML to call get_y_pred() on X_trainthe TS model's predict() method expects X to have timestamps, but during
internal validation, X_train can be empty or malformed.
Steps to reproduce
Script for reproduction