-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Pipeline requires both fit and transform method to be available instead of only fit_transform #16710
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
Comments
Yes, tsne, at least in our conception and implementation of it, does not induce a model that can be applied to a test set.. |
Tsne is transductive only |
That's a fair point, I was trying to use it for a single pass pipeline, essentially. I see how the lack of an internal model could become an issue once test data is introduced. Anyways, thanks for the explanation. |
Oh, I didn't note that you made no attempt to run any methods on the pipeline. I agree that it should be possible to construct the pipeline and run fit_transform on it, even if it is a somewhat degenerate pipeline. Thanks for reporting! |
In that case, what should the behavior be? Should it check the |
I would go for the latter. It's a degenerate pipeline but users would expect it to work. It would require to change https://github.com/scikit-learn/scikit-learn/blob/95d4f0841/sklearn/pipeline.py#L179-L180 so that, if an intermediate step has only
An error should probably be raised if the last step is not compatible (i.e. is a predictor without a Edit: TSNE could be the last estimator of the pipeline, so the check should be run for all the steps. It might a good idea to perform a check on all the estimators first, to see if there is an estimator with limitations (only |
It should be fine to fit, but raise an error when transform or predict etc
are called. It might make it a bit of a nuisance for people who try putting
tsne in a pipeline and only get an error after fitting... So I wonder if
it's worth warning in the case that an intermediate step does not support
transform.
… |
I personally would just opt to warn in case an intermediate step only supports Is my assumption correct that the Since Also, in what way do |
if_delegate_has_method does not check the intermediate estimators, only the
final one.
FeatureUnion._validate_transformers handles all the transformers
identically. Pipeline._validate_steps has to handle the last step
differently.
|
Hi, |
Describe the bug
Calling a pipeline with a nonparametric function causes an error since the function
transform()
is missing. The pipeline itself calls the functionfit_transform()
if it's present. For nonparametric functions (the most prominent being t-SNE) a regulartransform()
method does not exist since there is no projection or mapping that is learned. It could still be used for dimensionality reduction.Steps/Code to Reproduce
Example:
Expected Results
A pipeline is created.
Actual Results
Output:
Possible Solution
Editing this https://github.com/scikit-learn/scikit-learn/blob/95d4f0841/sklearn/pipeline.py#L179
to the following in order to reflect the change:
Versions
The text was updated successfully, but these errors were encountered: