Need an example of a custom class whose instance is fed to sklearn Pipeline / make_pipeline to use with GridSearchCV
According to sklearn.pipeline.Pipeline documentation, the class whose instance is a pipeline element should implement fit() and transform(). I managed to create a custom class that has these methods and works fine with a single pipeline.
Now I want to use that Pipeline object as the estimator argument for GridSearchCV. The latter requires the custom class to have set_params() method, since I want to search over the range of custom instance parameters, as opposed to using a single instance of my custom class.
After I added set_params, I got an error message set_params() takes 0 positional arguments but 1 was given. If anyone has done it, please post a successful example when a custom class works with both Pipeline and GridSearchCV. All I can find online are examples of classes that are a part of sklearn.
Topic pipelines gridsearchcv scikit-learn python machine-learning
Category Data Science