마지막에 AUC 까지 넣은 함수를 어떻게 실행하는지 모르겠습니다.
179
작성한 질문수 12
def get_eval_by_threshold(y_test , pred_proba_c1, thresholds):
for custom_threshold in thresholds:
binarizer = Binarizer(threshold=custom_threshold).fit(pred_proba_c1)
custom_predict = binarizer.transform(pred_proba_c1)
print('임곗값:',custom_threshold)
get_clf_eval(y_test , custom_predict)
print()
get_eval_by_threshold(y_test, pred_proba[:,1].reshape(-1,1), thresholds)
밑에 이거 코드를 추가하고 실행하는 것이 아닌가요?
답변 1
0
안녕하십니까,
음, 질문을 정확히 이해하지 못했습니다만,
피마 인디언 당뇨병 예측에서 def get_eval_by_threshold(y_test , pred_proba_c1, thresholds) 함수 사용을 물어보신 건가요?
실습 예제 피마 인디언 당뇨병 예측.ipynb를 보시면 get_clf_eval() 함수가 아래와 같이 되어 있습니다.
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))
적어주신 get_clf_eval(y_test , custom_predict) 는 잘못되어 있습니다.
실습 예제의 get_eval_by_threshold()에서 get_clf_eval()함수의 인자는 세개 입니다.
get_clf_eval(y_test , custom_predict, pred_proba_c1) 입니다.
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)
그래서 호출은 get_eval_by_threshold(y_test, pred_proba[:,1].reshape(-1,1), thresholds ) 로 하시면 됩니다.
감사합니다.
모델 서빙과 관련된 강좌가 출시되는지 질문드립니다.
0
50
2
안녕하세요 열심히 수강중인 학생입니다
0
86
2
정수 인덱싱
0
86
2
넘파이 오류
0
108
2
11강 numpy의 axis 축 질문 드립니다.
0
106
2
Kaggle 에서 Santander customer satisfaction data 를 다운로드 되지가 않습니다.
0
92
2
Feature importances 를 보여주는 barplot 이 그래프로 안보여져요.
0
76
2
타이타닉 csv 파일이 주피터 화면에 보이지 않습니다.
0
83
2
타이타닉 csv 파일이 주피터 화면에 보이지 않습니다.
0
73
2
5강 강의 오류가 있어요.
0
90
1
실무에서 LTV 관련 모델 선택 질문입니다!
0
81
2
14강 강의 듣는중에 궁금한게 있어서 질문합니다~
0
75
3
파이썬 다운그레이 후 사이킷런 재설치
0
128
2
좋은 강의 감사합니다.
0
79
2
scoring 함수 음수값
0
72
2
6번 강의에 사이킷런, 파이썬, 아나콘다 각각 버전 일치 안 시키고 진행해도 강의 따라가 지나요?
0
108
2
분류 평가 정확도 예측
0
87
2
안녕하세요. 강의 들으면서 업무에 적용하고 싶은 수강생입니다.
0
114
1
카카오톡 채널 있나요
0
118
1
혹시 강의에서 사용하시는 ppt 받을 수 있는건가요
0
193
2
pca 스케일링 관련하여 질문드립니다.
0
109
2
주피터 대신 구글 코랩
0
184
2
강의에서 사용하는 pdf or ppt자료는 따로 없는 건가요?
0
155
2
실루엣 스코어..
0
91
2





