小编Beh*_*noo的帖子

Keras,训练期间验证集上的auc与sklearn auc不匹配

我将测试集用作验证集。我使用了与如何计算喀拉拉邦的接收运行特征(ROC)和AUC类似的方法

问题是我在训练期间的val_auc约为0.85,但是当我使用

fpr, tpr, _ = roc_curve(test_label, test_prediction)
roc_auc = auc(fpr, tpr)
Run Code Online (Sandbox Code Playgroud)

我得到0.60的auc。我知道他们使用不同的公式,并且流式auc可能与sklearn计算的公式不同。但是,差异非常大,我无法弄清是什么原因造成了这种差异。

# define roc_callback, inspired by https://github.com/keras-team/keras/issues/6050#issuecomment-329996505
def auc_roc(y_true, y_pred):
    # any tensorflow metric
    value, update_op = tf.contrib.metrics.streaming_auc(y_pred, y_true)

    # find all variables created for this metric
    metric_vars = [i for i in tf.local_variables() if 'auc_roc' in i.name.split('/')[1]]

    # Add metric variables to GLOBAL_VARIABLES collection.
    # They will be initialized for new session.
    for v in metric_vars:
        tf.add_to_collection(tf.GraphKeys.GLOBAL_VARIABLES, v)

    # force to update metric values …
Run Code Online (Sandbox Code Playgroud)

roc scikit-learn auc keras tensorflow

4
推荐指数
1
解决办法
1232
查看次数

标签 统计

auc ×1

keras ×1

roc ×1

scikit-learn ×1

tensorflow ×1