KFold验证中的ROC AUC指标

时间:2018-08-31 12:29:44

标签: python scikit-learn keras cross-validation roc

在执行KFold验证时,在Keras中使用ROC / AUC作为度量标准而不是“准确性”的最佳方法是什么?我尝试用sklearns“ roc_curve”和“ auc”替换“ accuracy”,但这没有用。

还:我如何访问'cross_val_score()'循环以绘制ROC曲线?

这是我的代码:

X = X.values
Y = Y.values

def create_baseline():
    model = Sequential()
    model.add(Dense(82, input_dim=82, kernel_initializer='normal', activation='relu'))
    model.add(Dense(50, activation='relu'))
    model.add(Dense(1, kernel_initializer='normal', activation='sigmoid'))
    model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
    return model

estimator = KerasClassifier(build_fn=create_baseline, epochs=100, batch_size=5, verbose=0)
kfold = KFold(n_splits=50, shuffle=True, random_state=True)
results = model_selection.cross_val_score(estimator, X, Y, cv=kfold)

print("Accuracy: %.3f%% (%.3f%%)" % (results.mean()*100.0, results.std()*100.0))

0 个答案:

没有答案