Learn

Great! Now that we have all the preprocessing done and coded succinctly using ColumnTransformer and 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.

Instructions

1.

Using preprocess from the previous exercise, create a new pipeline that takes this as the first step and then a LinearRegression model as the second.

2.

Fit the pipeline on the training data.

3.

Predict the pipeline on the test set.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?