Hi, This is a code from sklearn.pipeline.Pipeline: @property def transform(self): """Apply transforms, and transform with the final estimator
This also works where final estimator is ``None``: all prior transformations are applied. Parameters ---------- X : iterable Data to transform. Must fulfill input requirements of first step of the pipeline. Returns ------- Xt : array-like, shape = [n_samples, n_transformed_features] """ # _final_estimator is None or has transform, otherwise attribute error # XXX: Handling the None case means we can't use if_delegate_has_method if self._final_estimator is not None: self._final_estimator.transform return self._transform I don't understand why `self._final_estimator.transform` can be returned, ignoring all the previous transformers. However, when testing it works: ``` >>> p = make_pipeline(FunctionTransformer(lambda x: 2*x), >>> FunctionTransformer(lambda x: x-1)) >>> p.transform(np.array([[1,2]])) array([[1, 3]]) ``` Could somebody explain that to me? Best, Louis Abraham
_______________________________________________ scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn