有一个二分类问题,predict 为预测值,labels 为实际标签,请问一下如何显示预测值为 1 且预测正确的样本个数?
1
acone2003 OP np.sum(predict == 1 and labels==1 )这样写不对,该怎么写呀?求助
|
2
nekota Aug 16, 2018 via iPhone
result 是二维数组,[predict, label]
len(np.where(result==(1,1))[0]) |
3
diggerdu Aug 16, 2018 via iPhone
np.sum(predict > 0.5 == label)
|
4
ivechan Aug 16, 2018
没必要非得一条命令写吧?
在预测正确里,统计预测值为 1 的数量就行了。 或者你用 sklearn 之类的库的话,可以用库函数算出 confusion matrix。 这样 TP, TN, FP, FN 都有了。 |
5
acone2003 OP 谢谢楼上三位,楼上的每个建议我都要查半天资料,长了不少知识----我是个初学者。
回 diggerdu: 用 np.sum(predict > 0.5 == label)这条语句怎么出现这个警告呀? ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() |