[ENH] deep argument for get_fitted_params#117
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #117 +/- ##
=======================================
Coverage 81.92% 81.93%
=======================================
Files 30 30
Lines 2235 2236 +1
=======================================
+ Hits 1831 1832 +1
Misses 404 404 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
RNKuhns
left a comment
There was a problem hiding this comment.
Requested minor change to docstring.
Also, looking at this functionality more closely. I think we should consider how we want to use GET_FITTED_PARAMS_NESTING or whether we want to use one of two other options:
- Use tag to record this functionality (seems to fit definition, since it is developer instructions for getting things working (rather than config)
- Move to a more duck-typing approach. If a component implements get_fitted_params, we get its fitted parameters.
This wouldn't be a change in this PR, but something we should think about updating ahead of the v0.4.0 release in February.
| Parameters | ||
| ---------- | ||
| deep : bool, default=True | ||
| If True, will return fitted parameters for this estimator, |
There was a problem hiding this comment.
Maybe have this setup to use bulleted list?
How about:
def get_fitted_params(self, deep=True):
"""Get fitted parameters.
Requires estimator to be fitted.
Parameters
----------
deep : bool, default=True
Whether to return fitted parameters of components.
- If True, will return fitted parameters for this estimator, plus parameters of components.
- If False, only returns the fitted parameters for this estimator.
Returns
-------
fitted_params : dict of fitted parameters
Dictionary where keys are str names of fitted parameters and values are the fitted values.
Parameters of components are indexed as [componentname]__[paramname].
""" There was a problem hiding this comment.
Note that I also suggested minor updates to returns.
There was a problem hiding this comment.
Re the update to returns: think it's worth pointing out the recursion explicitly.
If you go over the abridged form, it is not clear to a reader whether recursion happens or not - strictly speaking, taking the description at face value with brutal mathematical precision, recursion would not occur, unless it is additionally stated.
There was a problem hiding this comment.
apologies - I realize my answer must not make sense, since I have mixed up the get_params pull request with this one, in my memory.
I have now adopted your suggestions, and also improved description coming from the get_params PR (which includes your suggestion for the return).
|
Hmm, about the two options:
Don't understand this one, could you explain?
Agreed - that's what |
Realized after re-reading that it was confusing. I was specifically thinking about |
|
Also -- on line 976 there is a call to |
RNKuhns
left a comment
There was a problem hiding this comment.
@fkiraly I posted 2 comments. The first one could be handled in a follow-on PR, since it doesn't deal specifically with this PR's changes. But I think it makes sense to be handled using that system.
The second comment deals with functionality in this PR. Want to make sure that wasn't a missed update. Seems like a spot where we want to pass the deep parameter down to the call of that functionality on a BaseEstimator component.
Strictly speaking no, it wasn't logically wrong, because the However, I agree that it is more error prone in changes, e.g., to the default of The test that certified that "all was good" is the line |
I see, thanks for explaining. I would agree that it should be a tag or config. I would tend towards a config, since it is not a "property of the estimator" but behaviour modifying in a way that a user or interface may want to repeat with different values. |
|
(comments are addressed - no.1 by explanation & change in code; no.2 by saying, let's do this once we have config interface if you agree) |
Totally agree on that. I'll make an issue about that. |
|
This LGTM. Will merge once tests have run and passed. |
This adds a boolean
deepargument toget_fitted_paramswhich behaves precisely as the argument of the same name, ofget_params(see docstring in this PR). Mirror of sktime/sktime#4113Besides the additional user option, this would make a subsequent translation of the
get_paramsandget_fitted_paramsinterfaces for the meta-estimator much simpler due to the congruence of the meta-estimator utility, see sktime/sktime#4110