Mô hình hóa Rủi ro Tín dụng bằng Python
Michael Crabtree
Data Scientist, Ford Motor Company
# Chọn một vài cột cụ thể
X_multi = cr_loan_prep[['loan_int_rate','person_emp_length']]
# Chọn toàn bộ dữ liệu trừ loan_status
X = cr_loan_prep.drop('loan_status', axis = 1)
.get_booster() và .get_score()# Huấn luyện mô hình
clf_gbt.fit(X_train,np.ravel(y_train))
# In độ quan trọng đặc trưng
clf_gbt.get_booster().get_score(importance_type = 'weight')
{'person_home_ownership_RENT': 1, 'person_home_ownership_OWN': 2}
# Độ quan trọng cột với 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}
| Cột | Độ quan trọng | Độ chính xác mô hình | Recall mặc định mô hình |
|---|---|---|---|
| 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()Mô hình hóa Rủi ro Tín dụng bằng Python