Isolation trees

R 中的異常偵測入門

Alastair Rushworth

Data Scientist

Isolation tree

R 中的異常偵測入門

Isolation tree 圖

R 中的異常偵測入門

訓練一棵 isolation tree

library(isofor)

furniture_tree <- iForest(data = furniture, nt = 1)

iForest() arguments

  • data - dataframe
  • nt - 要生成的 isolation trees 數量

 

 

套件下載自 https://github.com/Zelazny7/isofor

R 中的異常偵測入門

產生 isolation 分數

furniture_score <- predict(furniture_tree, newdata = furniture)

predict() arguments

  • object - 已配適的 iForest 模型
  • newdata - 要評分的資料
R 中的異常偵測入門

解讀 isolation 分數

furniture_score[1:10]
[1] 0.5820092 0.5820092 0.5439338 0.5820092 0.5439338 
[6] 0.5820092 0.7129862 0.5363547 0.5363547 0.5363547

標準化路徑長度

  • 分數介於 0 到 1 之間
  • 接近 1 表示異常(路徑較短)
R 中的異常偵測入門

一起來練習吧!

R 中的異常偵測入門

Preparing Video For Download...