the pipeline class is not restricted to preprocessing and classificationbut can in fact join any number of estimators together for exampleyou could build pipeline containing feature extractionfeature selectionscalingand classificationfor total of four steps similarlythe last step could be regression or clustering instead of classification the only requirement for estimators in pipeline is that all but the last step need to have transform methodso they can produce new representation of the data that can be used in the next step internallyduring the call to pipeline fitthe pipeline calls fit and then transform on each step in turn, with the input given by the output of the transform method of the previous step for the last step in the pipelinejust fit is called brushing over some finer detailsthis is implemented as follows remember that pipe line steps is list of tuplesso pipeline steps[ ][ is the first estimatorpipe line steps[ ][ is the second estimatorand so onin[ ]def fit(selfxy)x_transformed for nameestimator in self steps[:- ]iterate over all but the final step fit and transform the data x_transformed estimator fit_transform(x_transformedyfit the last step self steps[- ][ fit(x_transformedyreturn self when predicting using pipelinewe similarly transform the data using all but the last stepand then call predict on the last stepin[ ]def predict(selfx)x_transformed for step in self steps[:- ]iterate over all but the final step transform the data x_transformed step[ transform(x_transformedfit the last step return self steps[- ][ predict(x_transformed or just fit_transform algorithm chains and pipelines