-
카테고리
-
세부 분야
딥러닝 · 머신러닝
-
해결 여부
미해결
roc auc 최종 점수 도출
20.12.02 04:07 작성 조회수 209
0
안녕하세요
좋은 강의 정말 감사드립니다.
3. evalation 마지막 셀에 roc-auc까지 포함된 get_clf_eval 함수를 정의해주시고 코드가 끝나는데,
해당 셀의 마지막에 (다른 셀들 처럼)
thresholds = [0.4 , 0.45 , 0.50 , 0.55 , 0.60] pred_proba = lr_clf.predict_proba(X_test) get_eval_by_threshold(y_test, pred_proba[:,1].reshape(-1,1), thresholds)
을 넣고 실행하면, Input contains NaN, infinity or a value too large for dtype('float64'). 이라는 에러 메시지가 뜹니다.
이것을 어떻게 해결할 수 있을까요?
답변을 작성해보세요.
0
0
권 철민
지식공유자2020.12.02
get_eval_by_threshold()도 아래와 같이 바뀌어야 합니다. 이어지는 강의에서 해당 함수 변경에 대해서 설명 드립니다.
from sklearn.preprocessing import Binarizer
def get_eval_by_threshold(y_test , pred_proba_c1, thresholds):
# thresholds 리스트 객체내의 값을 차례로 iteration하면서 Evaluation 수행.
for custom_threshold in thresholds:
binarizer = Binarizer(threshold=custom_threshold).fit(pred_proba_c1)
custom_predict = binarizer.transform(pred_proba_c1)
print('임곗값:',custom_threshold)
# roc_auc_score 관련 수정
get_clf_eval(y_test , custom_predict, pred_proba_c1)
감사합니다.
0
nathan
질문자2020.12.02
<<<수업용 코드>>>>
# 최종 함수의 도출
def get_clf_eval(y_test, pred=None, pred_proba=None):
confusion = confusion_matrix( y_test, pred)
accuracy = accuracy_score(y_test , pred)
precision = precision_score(y_test , pred)
recall = recall_score(y_test , pred)
f1 = f1_score(y_test,pred)
# ROC-AUC 추가
roc_auc = roc_auc_score(y_test, pred_proba)
print('오차 행렬')
print(confusion)
# ROC-AUC print 추가
print('정확도: {0:.4f}, 정밀도: {1:.4f}, 재현율: {2:.4f},\
F1: {3:.4f}, AUC:{4:.4f}'.format(accuracy, precision, recall, f1, roc_auc))
<<<<추가한 부분>>>>
thresholds = [0.4 , 0.45 , 0.50 , 0.55 , 0.60]
pred_proba = lr_clf.predict_proba(X_test)
get_eval_by_threshold(y_test, pred_proba[:,1].reshape(-1,1), thresholds)
<<결과 및 에러메시지>>
0
답변 4