Skip to content

Problem defining a custom transformer applied as the second step of a pipeline fed with a pandas dataframe #28917

Answered by ogrisel
paranjapeved15 asked this question in Q&A
Discussion options

You must be logged in to vote

A couple of remarks:

  • the make_pipeline call is invalid: you should either call make_pipeline(onehot, get_score) or call the constructor of the Pipeline class with a list of named steps tuples.
  • the custom estimator is not a valid transformer, for instance the fit method should return the estimator itself (return self). See https://scikit-learn.org/dev/developers/develop.html#apis-of-scikit-learn-objects for more details.
  • your transformer does not seem to need to stored any training set derived state information: it seems to be stateless. In this case it might be more natural to just write the transform logic as a simple Python function and wrap it with FunctionTransformer to use it in a p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ogrisel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #28877 on April 30, 2024 09:47.