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

[question] can hydra-sklearn-pipeline support function parameters for FunctionTransformer of sklearn #2

Open
muliliao opened this issue May 19, 2022 · 1 comment

Comments

@muliliao
Copy link

muliliao commented May 19, 2022

my config is:
target: hydra_sklearn_pipeline.make_pipeline
recursive: False

steps_config: # use yaml list syntax to preserve to order
- custom_transformer:
target: sklearn.preprocessing.FunctionTransformer
func: np.log1p

then it will report error like this:
File "D:\ProgramFiles\Python\Python37\lib\site-packages\sklearn\preprocessing_function_transformer.py", line 171, in _transform
return func(X, **(kw_args if kw_args else {}))
TypeError: 'str' object is not callable

it's because it treat the function "np.log1p" as string.
so is there any approach to support function parameters?
thanks.

@elisim
Copy link
Owner

elisim commented Jan 4, 2023

Thank you for reading the post, and submitting this issue :)

Maybe you can use _partial_ initialization? like the example here.
Alternatively, consider implementing a new transformer class (e.g. MyLogTransformer) and initialize it with Hydra.

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

No branches or pull requests

2 participants