시작하기무료로 시작하기

모델 리포트 비교

이제까지 로지스틱 회귀 모델과 Gradient Boosted Trees를 사용해 보셨죠. 이제 두 모델을 비교해 최종 예측에 사용할 모델을 결정해 볼까요?

서로 다른 모델의 부도 확률 예측 성능을 비교할 때 가장 쉬운 첫 단계 중 하나는 classification_report()의 지표를 확인하는 것입니다. 이를 통해 모델별 다양한 평가 지표를 한눈에 나란히 비교할 수 있어요. 데이터와 모델이 일반적으로 소수의 부도로 불균형한 경우가 많기 때문에, 우선은 부도 클래스의 지표에 집중해 주세요.

학습된 모델 clf_logisticclf_gbt, 그리고 각 모델의 예측값 preds_df_lrpreds_df_gbt가 워크스페이스에 로드되어 있습니다. 각 모델에는 0.4의 컷오프를 사용했어요. 테스트 세트 y_test도 준비되어 있습니다.

이 연습은 강의의 일부입니다

Python으로 배우는 신용 리스크 모델링

강의 보기

연습 안내

  • 로지스틱 회귀 예측에 대해 classification_report()를 출력하세요.
  • Gradient Boosted Tree 예측에 대해 classification_report()를 출력하세요.
  • precision_recall_fscore_support()를 사용해 로지스틱 회귀의 F-1 Score macro average를 출력하세요.
  • precision_recall_fscore_support()를 사용해 Gradient Boosted Tree의 F-1 Score macro average를 출력하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Print the logistic regression classification report
target_names = ['Non-Default', 'Default']
print(____(____, ____['loan_status'], target_names=target_names))

# Print the gradient boosted tree classification report
print(____(____, ____['loan_status'], target_names=target_names))

# Print the default F-1 scores for the logistic regression
print(____(____,____['loan_status'], average = 'macro')[2])

# Print the default F-1 scores for the gradient boosted tree
print(____(____,____['loan_status'], average = 'macro')[2])
코드 편집 및 실행