Model Pipelines Workout
- 01:39
How to create classification model pipelines in Python, focusing on logistic regression with L1 and L2 penalties.
Downloads
No associated resources to download.
Glossary
Machine Learning model pipeline PythonTranscript
To create each pipeline, use the format that you see here. First, the make pipeline function, and as the first argument, the standard scaler function, followed by the name of the model. And then for arguments inside that model, write the first argument and the first value, followed by the second argument and the second value and so on. For this exercise, create a pipeline dictionary named pipelines, just like you did for your regression algorithm, and it should contain the following items, using each main bullet as the key and each pipeline as the value. And because of an update to the Scikit-learn package, you're going to need to add the solver argument to your L1 and L2 logistic regression pipelines using the value liblinear like you see here.
Here we're starting by creating the pipelines dictionary and then creating one item for each of our four classification models. We're using the make pipeline function, which is familiar from our regression model. The first argument is the StandardScaler function, followed by the model that we're going to use in the logistic regression. We have to indicate if we're using the L1 penalty or the L2 penalty, which changes the type of regularization that's used in the model. For all four models we're passing the random state one so that your results are the same as you see in this video. Also, remember that because of that update to the Scikit-learn package, you're going to need to add this solver argument with the value lib linear, and that's only for your logistic regression, L1 and L2 pipelines, and you can add it right here after your random state argument.