我正在使用Scikit-Learn KerasRegressor
比较两个关于StandardScaler
的程序的效果:一个程序使用Scikit-Learn Pipeline
,一个程序没有Pipeline
。
计划1:
estimators = []
estimators.append(('standardise', StandardScaler()))
estimators.append(('multiLayerPerceptron', KerasRegressor(build_fn=build_nn, nb_epoch=num_epochs, batch_size=10, verbose=0)))
pipeline = Pipeline(estimators)
log = pipeline.fit(X_train, Y_train)
Y_deep = pipeline.predict(X_test)
计划2:
scale = StandardScaler()
X_train = scale.fit_transform(X_train)
X_test = scale.fit_transform(X_test)
model_np = KerasRegressor(build_fn=build_nn, nb_epoch=num_epochs, batch_size=10, verbose=0)
log = model_np.fit(X_train, Y_train)
Y_deep = model_np.predict(X_test)
我的问题是,程序1可以使R2得分为0.98(平均3次试验),而程序2只能达到R2得分为0.84(平均3次试验)。有人可以解释这两个程序之间的区别吗?