Python에서 RocCurve 시각화하기.
2019. 5. 18. 15:23ㆍ분석 Python/Visualization
728x90
딱히 함수로 지정되어있지 않은 것 같아서 공유합니다. + 저도 나중에 찾아서 보기 편하게 보려고요 ㅎㅎㅎ
def rocvis(true , prob , label ) :
from sklearn.metrics import roc_curve
if type(true[0]) == str :
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()
true = le.fit_transform(true)
else :
pass
fpr, tpr, thresholds = roc_curve(true, prob)
plt.plot(fpr, tpr, marker='.', label = label )
fig , ax = plt.subplots(figsize= (20,10))
plt.plot([0, 1], [0, 1], linestyle='--')
rocvis(test_y , Rf_prob[:,1] , "RandomFoest")
rocvis(test_y , GBM_prob[:,1] , "GBM")
rocvis(test_y , xgbprob[:,1] , "LightGBM")
rocvis(caty_Test , catprob[:,1] , "CatBoost")
plt.legend(fontsize = 18)
plt.title("Models Roc Curve" , fontsize= 25)
plt.show()

https://scikit-learn.org/stable/auto_examples/model_selection/plot_roc.html
Receiver Operating Characteristic (ROC) — scikit-learn 0.21.1 documentation
Note Click here to download the full example code Receiver Operating Characteristic (ROC) Example of Receiver Operating Characteristic (ROC) metric to evaluate classifier output quality. ROC curves typically feature true positive rate on the Y axis, and fa
scikit-learn.org
728x90
'분석 Python > Visualization' 카테고리의 다른 글
파이썬에서 R처럼 gather 함수와 자주 쓸 것 같은 시각화 코드 (0) | 2019.07.06 |
---|---|
Python Group 별로 Bar Graph 그릴 때, (0) | 2019.06.09 |
Confusion matrix 시각화 (0) | 2019.05.14 |
Jupyter에서 Plotly로 Bargraph Button 구현하기 (0) | 2019.05.12 |
[ Python ] 이미지를 gif로 바꾸는 방법 (0) | 2019.05.11 |
데이터분석뉴비님의
글이 좋았다면 응원을 보내주세요!