Gradient Boosted Trees 평가하기
이제 XGBClassifier() 모델을 사용해 부도 확률을 예측해 보셨죠. 이들 모델은 .predict() 메서드를 사용해 loan_status의 실제 클래스 값을 직접 예측할 수도 있어요.
아직 임곗값을 설정하지 않았다는 점을 염두에 두고, classification_report()의 지표를 확인해 모델의 초기 성능을 살펴보세요.
데이터 세트 cr_loan_prep, X_test, y_test는 이미 작업 공간에 로드되어 있어요. 모델 clf_gbt도 준비되어 있습니다. 로지스틱 회귀에 대한 classification_report()는 자동으로 출력돼요.
이 연습은 강의의 일부입니다
Python으로 배우는 신용 리스크 모델링
연습 안내
X테스트 데이터에 대해loan_status값을 예측하고, 결과를gbt_preds에 저장하세요.gbt_preds의 내용을 확인해 부도 확률이 아니라 예측된loan_status클래스 값이 담겨 있는지 확인하세요.- 모델의 성능을
y_test와 비교하는classification_report()를 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Predict the labels for loan status
____ = clf_gbt.____(____)
# Check the values created by the predict method
print(____)
# Print the classification report of the model
target_names = ['Non-Default', 'Default']
print(classification_report(____, ____, target_names=target_names))