从 Sci-Keras 而不是 Keras 导入 KerasRegresor 会改变我 cross_val_score 的结果。我如何解读新数字?

Importing KerasRegresor from Sci-Keras rather than Keras changes the results of my cross_val_score. How do I interpret the new numbers?

我正在 运行 进行交叉验证以测试我的神经网络。在安装 TensorFlow 2.0 之前,我使用

from keras.wrappers.scikit_learn import KerasRegressor
...
estimators.append(('mlp', KerasRegressor(build_fn=baseline_model, epochs=20, batch_size=50, verbose=0)))

并且交叉验证的结果是合理的均方误差数:

[  -31.93300056   -59.4023819    -21.60458565    -8.83761978
 -123.875         -3.63722825   -17.61767197   -30.63367081
    -235.83544922   -98.66159058]

然而,在安装 TensorFlow2.0 后,我收到警告:“DeprecationWarning: KerasRegressor is deprecated, use Sci-Keras (https://github.com/adriangb/scikeras) instead."

所以我安装了 scikeras,并使用

import scikeras
from scikeras.wrappers import KerasRegressor
...
estimators.append(('mlp', KerasRegressor(model=baseline_model, epochs=20, batch_size=50, verbose=0)))

但是交叉验证的结果是这样的:

[-0.00337219 -0.02298305 -0.03263641  0.03091023  0.04092502  0.02182378
 0.01505978  0.00197443  0.28461275  0.01479353]

这是不切实际的均方误差数。

发生了什么,为什么这些数字变化如此之大?

看来你得到的分数是标准化的。我没有检查 Keras Wrapper 以了解它是如何工作的,但在 scikeras 的 wrapper 中提到:

KerasRegressor uses sklearn_r2_score by default.

也许这可以解释为什么所有分数都在 0-1 之间。