import numpy as np
array_P=[np.random.randint(0,2,10)]
array_A=[np.random.randint(0,2,10)]
代码如下
print(array_P)
print(array_A)
TP=0
FP=0
FN=0
for i in range(10):
if array_P[i]==1 and array_A[i]==1:
TP+=1
elif array_P[i]==1 and array_A[i]==1:
FP+=1
elif array_P[i]==0 and array_A[i]==1:
FN+=1
print(TP)
print(FP)
print(FN)
P=TP/(TP+FP)
R=TP/(TP+FN)
fl_score = (2*R*P)/(R+P)
print('name:', fl_score)
报错
runfile('D:/python/files/未命名0.py')
[array([1, 0, 1, 1, 0, 0, 0, 0, 1, 0])]
[array([1, 1, 0, 1, 1, 0, 1, 0, 0, 1])]
Traceback (most recent call last):
File "D:\python\files\未命名0.py", line 30, in
if array_P[i]==1 and array_A[i]==1:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()