Skip to content

fix(models): apply model_config__* keys when no model_config was given - #614

Open
ChrisW09 wants to merge 1 commit into
mainfrom
fix/set-params-nested-model-config
Open

ChrisW09 wants to merge 1 commit into
mainfrom
fix/set-params-nested-model-config

Conversation

@ChrisW09

Copy link
Copy Markdown
Collaborator

Fixes #613

Problem

SklearnBase.set_params() applied model_config__* keys only when the estimator held a model_config object. An estimator constructed with, e.g., only a trainer_config trains from a default config object, but nested keys for it were dropped without an error. A GridSearchCV over model_config__layer_sizes then trained every candidate with the default architecture.

Fix

When model_config__* keys arrive and model_config is None, set_params() adopts the default config that fit() builds from (self.config) as model_config and applies the keys to it. fit(), get_params() and clone() therefore all see the tuned values. A default-constructed estimator, which holds no config objects at all, still rejects nested keys with ValueError, 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() and clone() show the tuned layer_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 main and 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_config is omitted, model_config__* keys tune the default model config, which get_params() then reports as model_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)

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] model_config__* keys are silently ignored when the estimator was built without a model_config

1 participant