Great! Now that we have all the preprocessing done and coded succinctly using
Pipeline, we can add a model. We will take the result at the end of the previous exercise, and now create a final pipeline with the
ColumnTransformer as the first step, and a
LinearRegression model as the second step.
By adding a model to the final step, the last step no longer has a
.transform method. This is the only step in a pipeline that can be a non-transformer. But now the final step also has a
.predict method, which can be called on the entire pipeline.
preprocess from the previous exercise, create a new pipeline that takes this as the first step and then a
LinearRegression model as the second.
Fit the pipeline on the training data.
Predict the pipeline on the test set.