October 2018
Intermediate to advanced
172 pages
4h 6m
English
Scaling your data and providing a level of standardization is a vital step in any linear regression pipeline, as it could offer a way to enhance the performance of your model. In order to scale the data, we use the following code:
from sklearn.preprocessing import StandardScalerfrom sklearn.pipeline import Pipeline#Setting up the scaling pipeline pipeline_order = [('scaler', StandardScaler()), ('linear_reg', linear_model.LinearRegression())]pipeline = Pipeline(pipeline_order)#Fitting the classfier to the scaled dataset linear_reg_scaled = pipeline.fit(X_train, y_train)#Extracting the score linear_reg_scaled.score(X_test, y_test)
We use the same scaling pipeline that we used in all of the previous chapters. In the preceding ...
Read now
Unlock full access