1. 程式人生 > >sklearn.metrics中的評估方法(accuracy_score,recall_score,roc_curve,roc_auc_score,confusion_matrix)

sklearn.metrics中的評估方法(accuracy_score,recall_score,roc_curve,roc_auc_score,confusion_matrix)

sklearn.metrics.accuracy_score(y_true, y_pred, normalize=True, sample_weight=None)

normalize:預設值為True,返回正確分類的比例;如果為False,返回正確分類的樣本數


>>>import numpy as np

>>>from sklearn.metrics import accuracy_score

>>>y_pred = [0, 2, 1, 3]

>>>y_true = [0, 1, 2, 3]

>>>accuracy_score(y_true, y_pred)

0.5

>>>accuracy_score(y_true, y_pred, normalize=False)

2