Python을 활용한 신용 위험 모델링
Michael Crabtree
Data Scientist, Ford Motor Company
# Selects a few specific columns
X_multi = cr_loan_prep[['loan_int_rate','person_emp_length']]
# Selects all data except loan_status
X = cr_loan_prep.drop('loan_status', axis = 1)
.get_booster()와 .get_score() 메서드를 사용합니다# Train the model
clf_gbt.fit(X_train,np.ravel(y_train))
# Print the feature importances
clf_gbt.get_booster().get_score(importance_type = 'weight')
{'person_home_ownership_RENT': 1, 'person_home_ownership_OWN': 2}
# Column importances from importance_type = 'weight'
{'person_home_ownership_RENT': 1, 'person_home_ownership_OWN': 2}
plot_importance() 함수를 사용합니다xgb.plot_importance(clf_gbt, importance_type = 'weight')
{'person_income': 315, 'loan_int_rate': 195, 'loan_percent_income': 146}
| 열 | 중요도 | 모델 정확도 | 모델 기본 재현율 |
|---|---|---|---|
| loan_int_rate, person_emp_length | (100, 100) | 0.81 | 0.67 |
| loan_int_rate, person_emp_length, loan_percent_income | (98, 70, 5) | 0.84 | 0.52 |
classification_report()의 일부로 표시됩니다Python을 활용한 신용 위험 모델링