简体   繁体   English

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

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

I am trying to find False positive rate.我试图找到误报率。 I have false positive and true negative value and I am trying this line of code我有误报和真负值,我正在尝试这行代码

    # 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)

But its not working giving me unspupported operand type error.但它不起作用给我不支持的操作数类型错误。 I guess values from tf.keras.metrics.TrueNagatives() are not int right So how Do I calculate false postive rate then我猜来自 tf.keras.metrics.TrueNagatives() 的值不正确 那么我如何计算假阳性率

According to the docs , you still have to call .result().numpy() on the values.根据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