Keras回归使用Scikit了解StandardScaler与管道和无管道

时间:2017-05-06 04:27:53

标签: python scikit-learn keras pipeline

我正在使用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次试验)。有人可以解释这两个程序之间的区别吗?

0 个答案:

没有答案