視覺化 isolation 分數

R 中的異常偵測入門

Alastair Rushworth

Data Scientist

建立數值序列

h_seq <- seq(min(furniture$Height), max(furniture$Height), length.out = 20)

w_seq <- seq(min(furniture$Width),  max(furniture$Width),  length.out = 20)

 

seq() 參數

  • from-上界
  • to-下界
  • length.out-序列中的值數
R 中的異常偵測入門

建立格點

furniture_grid <- expand.grid(Width = w_seq, Height = h_seq)

head(furniture_grid)
     Width Height  
1 46.85100 44.359 
2 51.48663 44.359 
3 56.12225 44.359 
4 60.75788 44.359 
5 65.39351 44.359 
6 70.02913 44.359 
R 中的異常偵測入門

為格點評分

furniture_grid$score <- predict(furniture_forest, furniture_grid)
R 中的異常偵測入門

繪製等高線圖!

library(lattice)
contourplot(score ~ Height + Width, data = furniture_grid, 
            region = TRUE)

R 中的異常偵測入門

一起來練習吧!

R 中的異常偵測入門

Preparing Video For Download...