繁体   English   中英

如何在 tf.keras.metrics 中找到误报率

[英]how to find false positive rate in tf.keras.metrics

我试图找到误报率。 我有误报和真负值,我正在尝试这行代码

    # calculate false positives and negatives based on the predicted output vs. expected output
fp = tf.keras.metrics.FalsePositives()
fp.update_state(bigy[test], pred)
fn = tf.keras.metrics.FalseNegatives()
fn.update_state(bigy[test], pred)
tn = tf.keras.metrics.TrueNegatives()
tn.update_state(bigy[test], pred)
#Find flase positive rate.
# fpr = false postive rate, fp = false positive, tn is true negative.
fpr = fp/(fp+tn)
#FPR = FP/(FP+TN)

但它不起作用给我不支持的操作数类型错误。 我猜来自 tf.keras.metrics.TrueNagatives() 的值不正确 那么我如何计算假阳性率

根据docs ,您仍然必须对值调用.result().numpy()

fp = tf.keras.metrics.FalsePositives()
fp.update_state(bigy[test], pred)
fp = fp.result().numpy()

fn = tf.keras.metrics.FalseNegatives()
fn.update_state(bigy[test], pred)
fn = fn.result().numpy()

tn = tf.keras.metrics.TrueNegatives()
tn.update_state(bigy[test], pred)
tn = tn.result().numpy()

# Find false positive rate.
fpr = fp / (fp + tn)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM