fix(optimization): return inf when sampler picks no-feature config#638
Open
SAY-5 wants to merge 2 commits into
Open
fix(optimization): return inf when sampler picks no-feature config#638SAY-5 wants to merge 2 commits into
SAY-5 wants to merge 2 commits into
Conversation
Closes Nixtla#637. `mlforecast_objective`'s `objective` runs `config_fn(trial)` and hands the resulting MLForecast config straight to the model fit even when the sampled hyperparameters specify no input features (`lags`, `lag_transforms`, and `date_features` all `None`). That produces a zero-column feature matrix and sklearn raises: ValueError: at least one array or dtype is required The v1.0.2 objective guarded against this by returning `np.inf` so Optuna treated the trial as worst-case and moved on (see mlforecast/optimization.py:78-83 in v1.0.2). The guard was dropped in 1.0.3 (commit 7526c56) without a follow-up; restore it. Patch matches the snippet the reporter validated locally, plus a `set_user_attr("config")` so the skipped configs still show up in `study.trials_dataframe()` for diagnostics.
Author
|
All 14 other matrix runs (macOS / Ubuntu / Windows × Python 3.10, 3.13 + macOS/Windows 3.14) pass. Only |
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.
Closes #637.
mlforecast_objective'sobjectiverunsconfig_fn(trial)and hands the resulting MLForecast config straight to the model fit even when the sampled hyperparameters specify no input features (lags,lag_transforms, anddate_featuresallNone). That produces a zero-column feature matrix and sklearn raises:The v1.0.2 objective guarded against this case (optimization.py:78-83) and returned
np.infso Optuna treated the trial as worst-case and moved on. The guard was dropped in 1.0.3 (commit 7526c56) without a follow-up. This restores it.Patch
Matches the snippet the reporter validated locally, plus a
trial.set_user_attr("config", ...)so the skipped configs still show up instudy.trials_dataframe()for diagnostics, keeps the existing diagnostics behavior consistent with successful trials.