Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中从混淆矩阵打印精度_Python_Scikit Learn - Fatal编程技术网

在python中从混淆矩阵打印精度

在python中从混淆矩阵打印精度,python,scikit-learn,Python,Scikit Learn,这是我的密码: from sklearn.metrics import confusion_matrix cm = confusion_matrix(y_test, y_pred) 这就是我得到的 0 1 0 [[102 39] 1 [ 73 29]] 我怎样才能打印分数29/(29+39),这意味着我的confusiin矩阵的精度?您需要的是sklearn 据说它返回: 每节课的精确性、召回率、F1成绩的文字总结 以下是一个例子: from sklea

这是我的密码:

from sklearn.metrics import confusion_matrix

cm = confusion_matrix(y_test, y_pred)
这就是我得到的

       0    1
 0  [[102  39]
 1   [ 73  29]]
我怎样才能打印分数
29/(29+39)
,这意味着我的confusiin矩阵的精度?

您需要的是sklearn

据说它返回:

每节课的精确性、召回率、F1成绩的文字总结

以下是一个例子:

from sklearn.metrics import classification_report
y_true = [0, 1, 0, 1, 0]
y_pred = [0, 0, 1, 1, 1]
target =["yes", "no"]
print(classification_report(y_true, y_pred, target_names=target))
以及输出:


看一下。非常感谢。这正是我想要的。请同时添加示例用法,使其成为一个好的答案。目前,这似乎是唯一的答案,这是不鼓励在这里。