異常分數
你的視覺化結果顯示,甲狀腺疾病可能可以從異常的荷爾蒙測量中偵測出來。
在這個練習中,你將使用 isolation forest 為甲狀腺指標產生異常分數,並把該分數與真實的疾病標籤做比較。
本練習屬於課程
R 中的異常偵測入門
練習說明
- 以
thyroid的荷爾蒙測量資料來訓練一個 isolation forest。 - 為甲狀腺資料產生異常分數,並將結果附加為
thyroid中名為iso_score的新欄位。 - 使用
boxplot()函式,利用label欄位,比較有甲狀腺疾病與無甲狀腺疾病病患之間的分數分佈。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Fit isolation forest
thyroid_forest <- iForest(___, ___ = 200, phi = 100)
# Anomaly score
thyroid$iso_score <- predict(thyroid_forest, ___)
# Boxplot of the anomaly score against labels
boxplot(___ ~ ___, ___, col = "olivedrab4")