視覺化欄位重要性
當模型使用不同的欄位組合進行訓練時,效能會改變;但同一個欄位的「重要性」會不會因為所屬的組合不同而改變呢?
資料集 X2 與 X3 是用以下程式碼建立的:
X2 = cr_loan_prep[['loan_int_rate','person_emp_length']]
X3 = cr_loan_prep[['person_income','loan_int_rate','loan_percent_income']]
了解不同欄位如何被用來預測 loan_status,對於提升模型可解釋性非常重要。
工作區已載入資料集 cr_loan_prep、X2_train、X2_test、X3_train、X3_test、y_train、y_test。
本練習屬於課程
以 Python 進行信用風險建模
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Train a model on the X data with 2 columns
____ = xgb.____().____(____,np.ravel(____))
# Plot the column importance for this model
xgb.____(____, importance_type = 'weight')
plt.____()