Repository navigation
Conversation
An estimator constructed with only a trainer_config or preprocessing_config trains from a default config object, but set_params() dropped nested model_config__* keys for it, so searches over them trained the default architecture. The default config is now adopted as model_config and tuned. Fixes #613
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.
Fixes #613
Problem
SklearnBase.set_params()appliedmodel_config__*keys only when the estimator held amodel_configobject. An estimator constructed with, e.g., only atrainer_configtrains from a default config object, but nested keys for it were dropped without an error. AGridSearchCVovermodel_config__layer_sizesthen trained every candidate with the default architecture.Fix
When
model_config__*keys arrive andmodel_configisNone,set_params()adopts the default config thatfit()builds from (self.config) asmodel_configand applies the keys to it.fit(),get_params()andclone()therefore all see the tuned values. A default-constructed estimator, which holds no config objects at all, still rejects nested keys withValueError, as before.Tests
tests/models/test_estimator_configuration.py::TestSplitConfigSetParams:test_nested_model_config_keys_without_model_config_tune_the_default_config:config,get_params()andclone()show the tunedlayer_sizes.test_grid_search_over_nested_model_config_keys_without_model_config: the best estimator's first layer has the selected width.Both fail on
mainand pass with this change.Docs
The FAQ ("Does GridSearchCV work?") said nested keys "require the corresponding config object". It now says that when only
model_configis omitted,model_config__*keys tune the default model config, whichget_params()then reports asmodel_config.Checks
just test: 3238 passed, 46 skipped, 28 xfailed; coverage 91.29%just docs: build succeeded (warnings treated as errors)just check: all hooks passed (ruff, prettier, pyright)