Thief of Wealth
Published 2019. 9. 28. 22:48
ROC curve 그리기 개발/ML+ Data Science

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()


profile on loading

Loading...