October 2018
Intermediate to advanced
172 pages
4h 6m
English
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 StandardScalerfrom 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, ...Read now
Unlock full access