Although the model has performed extremely well, scaling the data is still a useful step in building machine learning models with logistic regression, as it standardizes your data across the same range of values. In order to scale your data, we will use the same StandardScaler() function that we used in the previous chapter. This is done by using the following code:
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
#Setting up the scaling pipeline
pipeline_order = [('scaler', StandardScaler()), ('logistic_reg', linear_model.LogisticRegression(C = 10, penalty = 'l1'))]
pipeline = Pipeline(pipeline_order)
#Fitting the classfier to the scaled dataset
logistic_regression_scaled = pipeline.fit(X_train, y_train)
#Extracting the score
logistic_regression_scaled.score(X_test, y_test)
The preceding code resulted...