from sklearn.metrics import roc_curve
cm = confusion_matrix(y_test, predict)
print(cm)
print( "accuracy : ", accuracy_score( y_test, predict ) ) # (cm[0][0]+cm[1][1])/(cm[0][0]+cm[1][1]+cm[1][0]+cm[0][1])
print( "recall(detection rate) : ", recall_score( y_test, predict ) )
print( "fallout (false alarm rate) : ",cm[1][0]/(cm[1][0]+cm[1][1]) )
print( "f1_score : ", f1_score(y_test, predict) )
print( "roc_auc : ", roc_auc_score(y_test, predict) )
fpr, tpr, threshold = roc_curve(y_test, predict)
plt.plot(fpr, tpr, 'o-', label="ROC Curve")
plt.plot([0,1],[0,1], 'k--')
fallout = cm[1][0]/(cm[1][0]+cm[1][1])
plt.plot([fallout], [recall_score( y_test, predict )], 'ro', ms=10)
plt.xlabel("fallout")
plt.ylabel("recall")
plt.title("ROC curve")
plt.show()
'개발 > ML+ Data Science' 카테고리의 다른 글
notebook image 불러와서 표시하기 (0) | 2019.09.29 |
---|---|
Kmeans알고리즘 elbow그래프 그려서 구하기 (0) | 2019.09.29 |
sklearn metric 설명들 (0) | 2019.09.28 |
Kmeans: '(slice(None, None, None), slice(None, None, None))' is an invalid key (0) | 2019.09.28 |
머신러닝 튜토리얼 추천사이트 (0) | 2019.09.28 |