Problem 9 (5 points, coding task)
Use StandardScaler that has been imported from sklearn.preprocessing (DO NOT IMPORT IT AGAIN) to do the following tasks.
-
Create an object called
scaler. -
Use
scaler.fit_transformto scale each column inX_trainto standard normal. Save the scaled training dataset asX_train_scaled. -
Use
scaler.transformto scaleX_test. Save the scaled test dataset asX_test_scaled. -
Add a column to
X_train_scaledwith all 1s. Do the same thing forX_test_scaled. -
Print the types of objects
X_train_scaledandX_test_scaled. -
Print the shapes of objects
X_train_scaledandX_test_scaled. -
Print the first five rows of
X_train_scaledandX_test_scaled.