我急切地启用了执行功能,但不确定如何从测试或培训数据中找到特异性值或假阳性等值
test_dataset = tf.data.TextLineDataset(fileid + "test")
test_dataset = test_dataset.map(parse_csv)
test_dataset = test_dataset.shuffle(buffer_size=1000)
test_dataset = test_dataset.batch(32)
test_accuracy = tfe.metrics.Accuracy()
for (x, y) in test_dataset:
prediction = tf.argmax(model(x), axis=1, output_type=tf.int32)
test_accuracy(prediction, y)
这里是代码,我已经确定了准确性,但是由于我的测试数据,它的准确率是90%,因此需要另一种分析数据的方法
答案 0 :(得分:0)
想办法了
truepositive = 0
falsepositive = 0
truenegative = 0
falsenegative = 0
y = y.numpy()
prediction = prediction.numpy()
for index in range(0,116):
if prediction[index] ==1 and prediction[index] ==y[index]:
truepositive = truepositive + 1
if prediction[index] ==0 and prediction[index] ==y[index]:
truenegative = truenegative + 1
if prediction[index] ==0 and prediction[index] !=y[index]:
falsenegative = falsenegative + 1
if prediction[index] ==1 and prediction[index] !=y[index]:
falsepositive = falsepositive + 1
print("sensitivity" + str(truepositive/(truepositive+falsenegative)))
print("specificity" + str(truenegative/(truenegative+falsepositive)) )