Skip to content

[ENH] set_params to recognize unique suffixes as aliases for full parameter string#229

Merged
fkiraly merged 1 commit into
mainfrom
set_params-sugar
Oct 25, 2023
Merged

[ENH] set_params to recognize unique suffixes as aliases for full parameter string#229
fkiraly merged 1 commit into
mainfrom
set_params-sugar

Conversation

@fkiraly
Copy link
Copy Markdown
Contributor

@fkiraly fkiraly commented Oct 7, 2023

Mirror of sktime/sktime#2931

This PR introduces experimental functionality to set_params to enable it to recognize unique suffixes as aliases for full parameter strings.

That is, in the example in sktime/sktime#2929, it enables set_params - and, in consequence, the param_grid of grid search - to recognize max_depth instead of forecaster__forecast__estimator__max_depth.

This is primarily meant as convenience sugar for the user of grid search or, more generally, set_params.

Contains tests for both nested parameter setting behaviour, as well as parameter key aliasing in nested composites.

@fkiraly fkiraly added the implementing framework Implementing core skbase framework label Oct 7, 2023
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 7, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (1b5d4a8) 83.55% compared to head (6b61d44) 83.64%.
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #229      +/-   ##
==========================================
+ Coverage   83.55%   83.64%   +0.09%     
==========================================
  Files          41       41              
  Lines        2833     2856      +23     
==========================================
+ Hits         2367     2389      +22     
- Misses        466      467       +1     
Files Coverage Δ
skbase/base/_base.py 79.22% <96.29%> (+1.11%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread skbase/tests/test_base.py
composite._components(SomeClass)


class AliasTester(BaseObject):

Check failure

Code scanning / CodeQL

Missing call to `__init__` during object initialization

Class AliasTester may not be initialized properly as [method BaseObject.__init__](1) is not called from its [__init__ method](2).
Comment thread skbase/tests/test_base.py
composite._components(SomeClass)


class AliasTester(BaseObject):

Check warning

Code scanning / CodeQL

`__eq__` not overridden when adding attributes

The class 'AliasTester' does not override ['__eq__'](1), but adds the new attribute [a](2). The class 'AliasTester' does not override ['__eq__'](1), but adds the new attribute [bar](3).
@fkiraly fkiraly merged commit d55abc6 into main Oct 25, 2023
fkiraly pushed a commit to sktime/sktime that referenced this pull request Nov 3, 2023
…r full parameter string (#2931)

Update: The logic in this PR became obsolete after merging it upstreak
in `scikit-base 0.6.1`, see
sktime/skbase#229

The PR still adds the tests in `sktime`, with a `scikit-base` version
condition, but does not add the logic anymore.

---

This PR introduces experimental functionality to `set_params` to enable
it to recognize unique suffixes as aliases for full parameter strings.

That is, in the example in
#2929, it
enables `set_params` - and, in consequence, the `param_grid` of grid
search - to recognize `max_depth` instead of
`forecaster__forecast__estimator__max_depth`.

This is primarily meant as convenience sugar for the user of grid search
or, more generally, `set_params`.

Contains tests for both nested parameter setting behaviour, as well as
parameter key aliasing in nested composites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

implementing framework Implementing core skbase framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants