Hi all,

I have what is probably a silly question.  I read this passage on [1]:

"""
The pipeline has all the methods that the last estimator in the pipeline has, 
i.e. if the last estimator is a classifier, the Pipeline can be used as a 
classifier. If the last estimator is a transformer, again, so is the pipeline.
"""

I'm trying to create a pipeline where my last estimator is a 
KNeighborsClassifier and, instead of predict(), I was hoping to use 
kneighbors().  But unfortunately, when in a pipeline, I'm getting this 
AttributeError:

  AttributeError: 'Pipeline' object has no attribute 'kneighbors'

Is kneighbors() really available from the Pipeline?  Or is there an alternative 
way to call an element in the Pipeline to use it?  I tried 
"pipe[-1].kneighbors(X)", but that doesn't seem to be applying the earlier 
transforms in the pipeline.

Thanks for any pointers,
matt

[1] https://scikit-learn.org/stable/modules/compose.html
_______________________________________________
scikit-learn mailing list
scikit-learn@python.org
https://mail.python.org/mailman/listinfo/scikit-learn

Reply via email to