Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h2o/sklearn/wrapper.py#params_as_h2o_frames fails to pass on **fit_params correctly to decorated function #7140

Closed
exalate-issue-sync bot opened this issue May 11, 2023 · 2 comments

Comments

@exalate-issue-sync
Copy link

When calling the fit method of a class like h2o.sklearn.H2OAutoMLRegressor and passing not only standard params X and y but also additional non-standard custom params which are bound to variable keyword param **fit_params, those fit_params will not be passed on correctly to the actual fit function by the fit function's decorator that has been created beforehand by h2o/sklearn/wrapper.py#params_as_h2o_frames. Instead those fit_params will end up one level too deeply nested in an envelope of type dictionary so that the decorated fit function cannot bind them anymore.

I have been able to fix the problem in my copy of the code by putting the following snippet into function params_as_h2o_frames:

{{
# PATCH BEGIN
# this patch is to ensure that custom keyword params bound to a var keyword parameter like fit_params
# are forwarded to the wrapped function fn in an unpacked way rather than as items of a dictionary
# which would not be recognised by the function fn
# result = fn(
_args) # this is the original line of code being replaced by the modified version to follow
var_keyword_param = {}
for param_name in sig.parameters.keys():
if sig.parameters[param_name].kind == Parameter.VAR_KEYWORD:
var_keyword_param = _args.pop(param_name)
break # there can only be at most one parameter of kind VAR_KEYWORD in any function signature
result = fn(**_args, **var_keyword_param)
# PATCH END
}}

@h2o-ops-ro
Copy link
Collaborator

JIRA Issue Details

Jira Issue: PUBDEV-8522
Assignee: Sebastien Poirier
Reporter: N/A
State: Resolved
Fix Version: 3.36.1.3
Attachments: N/A
Development PRs: Available

@h2o-ops-ro
Copy link
Collaborator

Linked PRs from JIRA

#6189
#6205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant