-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
WIP: extend Pipeline transform and inverse_transform behavior #2561
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
Conversation
…orresponding methods
# test the last step implements an inverse_transform method | ||
inverse_steps = self.steps[::-1] | ||
if not hasattr(self.steps[-1][-1], 'inverse_transform'): | ||
inverse_steps = self.steps[:-1][::-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please edit the docstring of the inverse_transform
method to explain that it works even if the last step does not support the inverse_transform
method and give motivation for this feature as done for the forward case?
Looks good to me. @schwarty please add a |
Done. @ogrisel and @GaelVaroquaux what do you think? |
@@ -60,6 +60,10 @@ Changelog | |||
- Added :class:`linear_model.RANSACRegressor` meta-estimator for the robust | |||
fitting of regression models. By Johannes Schönberger. | |||
|
|||
- Extended transform and inverse_transform methods from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add double back-ticks around code words like transform
and inverse_transform
.
Apart from the nitpick comment, LGTM. +1 for merge. |
As I just told @schwarty orally, I am not in favor of merging this PR, although I had backed the idea during our first discussions. I don't like the automatic change of behavior depending on subtle properties of the final learner. For instance changing the code to use an LDA instead of a LogisticRegression would have really strange consequences with this PR. |
Do you have an alternative API to propose? Maybe a new constructor param? I don't see your point with LDA. How this PR would change the behavior in this case? It is my understanding that only cases that would have previously raised an exception are now supported. |
Yes: with a LogisticRegression it would have raised an error, but not |
I agree with @GaelVaroquaux. It's a case of implicit behaviour that could bite you. What I wouldn't mind (though perhaps it's overkill and will create API problems) is for
|
Or, just as slicing a list with an integer returns an element and with a
|
I think that there is a consensus against merging this PR. @schwarty : is it OK with you if I close it. |
closing as @schwarty didn't object within the last 3 years |
I suppose it's good when people making more money still drink beers with you. :) |
Pipeline transform and inverse_transform skip last step if it lacks corresponding methods.
The extension is useful to:
coef_
attribute of a linear classifier for exampleDesign discussion here: Issue #2562