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.
BaseEstimator
to getset_params
andget_params
for free; the only caveat is that then your__init__
method's signature should contain precisely the attributes that get set in that method. Try stackoverflow.com/search?q=%5Bscikit-learn%5D+custom+class for some examples? $\endgroup$