開始使用免費開始

視覺化分類樹

為了遵守政府防止非法歧視的規定,放貸機構必須說明為何拒絕某筆貸款申請。

分類樹的結構可以用視覺化方式呈現,有助於理解樹是如何做出決策。上一個練習中你配適的模型 loan_model 已可供使用。

本練習屬於課程

R 監督式學習:分類

檢視課程

練習說明

  • 輸入 loan_model,查看分類樹的文字表示。
  • 載入 rpart.plot 套件。
  • 對該貸款模型套用 rpart.plot() 函式來視覺化此樹。
  • 執行提供的指令,看看更改其他繪圖參數如何影響視覺化結果。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Examine the loan_model object


# Load the rpart.plot package


# Plot the loan_model with default settings


# Plot the loan_model with customized settings
rpart.plot(loan_model, type = 3, box.palette = c("red", "green"), fallen.leaves = TRUE)
編輯並執行程式碼