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

Enabling passing of primitives/pipelines to hyperparameters #126

Open
dhruvsharma1992 opened this issue Apr 8, 2020 · 0 comments
Open

Comments

@dhruvsharma1992
Copy link

dhruvsharma1992 commented Apr 8, 2020

Description

I was trying to construct a primitive for sklearn.model_selection.RandomizedSearchCV when I found that the hyperparameter for estimator is itself can be a primitive.

What I Did

To go around the current implementation, I tried to create a pipeline for the estimator (using LogisticRegression) and passed that as the value for the hyperparameter estimator i input_params as follows:
init_params = {
"sklearn.model_selection.RandomizedSearchCV": {
'estimator': logistic_regression_pipeline,
'scoring': "accuracy",
'n_iter': 5
}
}

In python <3.7 it fails in deepcopy of hyperparameters (fix suggested here: https://stackoverflow.com/questions/6279305/typeerror-cannot-deepcopy-this-pattern-object)

In python 3.7+ it fails where sklearn throws the exception that the estimator object needs to be an object of type sklearn estimator and not MLPipeline

There needs to be a way to pass such primitives as input params

Note It works if I pass the logisticRegression object directly to the init_params as:
'estimator': LogisticRegression(random_state=0)

but looses the capability of:

  1. saving the pipeline to disk
  2. constructing the complete pipeline using only MLBlocks
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

1 participant