Reputation: 10131
I'm trying to define a quantizer to use with Pipeline/GridSearchCV in sklearn. When defining as below
class Quantizer(base.BaseEstimator, base.TransformerMixin):
def __init__(self):
def transform(X, y=None):
some code
I'm getting something like
method fit is missing
Am I missing something in the definition of the class?
Upvotes: 3
Views: 1507
Reputation: 40963
If you are only transforming data in an intermediate state of your pipeline you don't need to implement a fit method, so you just return self
:
class Quantizer(base.BaseEstimator, base.TransformerMixin):
def __init__(self):
def transform(self, X, y=None):
# some code
def fit(self, X, y=None, **fit_params):
return self
Take a look here for more details.
Upvotes: 8