0. StandardScaler
去均值时,在测试集上进行预测时减去的均值是训练集上得到的均值;
import sklearn.preprocessing as prepdef standard_scale(X_train, X_test): preprocessor = prep.StandardScaler().fit(X_train) X_train = preprocessor.transform(X_train) X_test = preprocessor.transform(X_test) return X_train, X_test
- 1
- 2
- 3
- 4
- 5
- 6
- 7