I'm reading through Hands-On Machine Learning with Scikit-Learn & TensorFlow. We're going over sklearn Transformation Pipelines for preparing data for the ML algorithms.
Here's the code (housing_num is a dataframe of the numerical attributes of the main dataframe housing):
num_pipeline = Pipeline([ ('imputer', Imputer(strategy='median')), ('attribs_adder', CombinedAttributesAdder()), ('std_scaler', StandardScaler()) ]) housing_num_tr = num_pipeline.fit_transform(housing_num)
The text explains, "The Pipeline constructor takes a list of name/estimator pairs defining a sequence of steps. All but the last estimator must be transformers (i.e., they must have a fit_transform() method)."
1) Why do we fit_transform() some, but only fit() without transforming others? I'm guessing this has to do with the difference between estimators and transformers, which I'm confused on in this context.
2) So when using Pipeline, you can only include one estimator that won't be transformed, and it has to be the last input? ("all but the last estimator must be transformers")