from sklearn.metrics import confusion_matrix from sklearn.metrics import accuracy_score from sklearn.metrics import classification_report # accuracy_score() y_true = [0,1,2,3] y_pred = [0,2,1,3] print(accuracy_score(y_true=y_true,y_pred=y_pred)) # confusion_matrix() y_true = [2,0,2,2,0,1] y_pred = [0,0,2,2,0,2] print(confusion_matrix(y_true,y_pred)) # classification_report() y_true = [0,1,2,2,2] y_pred = [0,0,2,2,1] print(classification_report(y_true,y_pred))
precision = 5 / 8 (预测中/视野)
recall = 5 / 12 (预测中/个数总和)
F1 - score = 2 * precision * recall / (precion + recall)