性能度量

R 异常检测入门

Alastair Rushworth

Data Scientist

使用决策阈值

选择一个高阈值

high_score <- quantile(sat$score, probs = 0.99)
high_score
    99% 
0.6228078

将分数二值化

sat$binary_score <- as.numeric(score >= high_score)
R 异常检测入门

一致性表

比较真实标签与二值化分数

table(sat$label, sat$binary_score)
       0    1
  0 5729    3
  1   15   56

  • 在 71 个异常中找到 56 个
R 异常检测入门

召回率

正确识别的异常 $\div$ 异常总数

  • 1 = 完全召回;算法检测到所有异常
table(sat$label, sat$binary_score)
       0    1
  0 5729    3
  1   15   56
recall <- 56 / (15 + 56)
recall
0.7887324
R 异常检测入门

精确率

正确识别的异常 $\mathbf{\div}$ 被判为异常的总数

  • 1 = 完全精确;无正常样本被误判
table(sat$label, sat$binary_score)
       0    1
  0 5729    3
  1   15   56
precision <- 56 / (56 + 3)
precision
0.9491525
R 异常检测入门

让我们来练习!

R 异常检测入门

Preparing Video For Download...