Repository navigation
Fix AttributeError when retraining rf/extra_tree without a search (max_iter 0 or 1) under a time budget - #1666
Open
Mohammad Sohail Shaikh (sohailshk) wants to merge 1 commit into
Conversation
…er a time budget LGBMEstimator.fit() (inherited by RandomForestEstimator and ExtraTreesEstimator) used self._t1 to cap the number of iterations by the remaining budget, but _t1 is only set by the timing fits of a search trial. With max_iter 0 or 1 the search is skipped and the initial config is retrained on a fresh estimator with the time budget still set, which raised AttributeError. Fall back to the configured number of iterations when no timing is available.
This branch has not been deployed
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.
Why are these changes needed?
LGBMEstimator.fit()(inherited byRandomForestEstimatorandExtraTreesEstimator) caps the iteration count by the remaining time budget usingself._t1, which only exists after the timing fits of a search trial.max_iter < 2skips the search and retrains the initial config on a fresh estimator with the time budget still set, so:max_iter=0fails the same way, including the documented zero-shot formmax_iter=0, starting_points="data", estimator_list=["rf", "lgbm"], time_budget=60(all run on main).extra_treealso fails; lgbm, xgboost, xgb_limitdepth, lrl1, sgd, kneighbor are fine. From code reading: themax_iter > 1path already setstime_budget = -1before retraining (automl.py), which is why searches never hit this. The fix keeps the configured iteration count when no timing exists.Tests (rf/extra_tree x max_iter 0/1, plus the zero-shot form): 5 failed on main, 5 pass. test_training_log, test_multiclass, test_regression, test_resampler, test_classification, test_extra_models: 99 passed; failures/error are missing-catboost cases that also fail on main.
Related issue number
none.
Checks
Checks run: black (line length 120) and ruff on the changed files. The pinned pre-commit hook versions were not run. No doc changes are needed.