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
According to the docs , you still have to call .result().numpy()
on the values.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.