含類別變數的 Isolation forest
正如你在影片中看到的,isolation forest 可以接受類別型特徵作為輸入,但前提是它們已編碼為 factor 變數。
在本練習中,你在前一個練習編輯過的 thyroid 資料已預先載入。為了更保險,在訓練 isolation forest 之前,你應先檢查所有特徵是否為 numeric 或 factor。
本練習屬於課程
R 中的異常偵測入門
練習說明
- 檢查
thyroid資料中的age和sex欄是否已編碼為 factor。 - 接著訓練一個包含 100 棵樹的 isolation forest。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Check the class of age column
___
# Check the class of sex column
___
# Fit an isolation forest with 100 trees
thyroid_for <- ___