Closed npow closed 1 year ago
HI @npow ,
You can use _ key to specify positional (not named) arguments if any.
from pipelinex import HatchDict
import yaml
from pprint import pprint # pretty-print for clearer look
params_yaml = """
metrics:
- =: functools.partial
_:
=: sklearn.metrics.roc_auc_score
multiclass: ovr
"""
parameters = yaml.safe_load(params_yaml)
metrics_dict = parameters.get("metrics")
print("### Before ###")
pprint(metrics_dict)
metrics = HatchDict(parameters).get("metrics")
print("\n### After ###")
print(metrics)
### Before ###
[{'=': 'functools.partial',
'_': {'=': 'sklearn.metrics.roc_auc_score'},
'multiclass': 'ovr'}]
### After ###
[functools.partial(<function roc_auc_score at 0x16bcf19d0>, multiclass='ovr')]
Awesome, that did it!
I'm trying to use
functools.partial
in HatchDict, but it seems to always require one argument which is not named. Is there any way to work around this?config: