如何处理发现的离群点

Python 中的异常检测

Bekhruz (Bex) Tuychiev

Kaggle Master, Data Science Content Creator

异常检测的应用

  • 医疗
  • 网络安全
  • 欺诈检测

进行两次分析:包含与不包含离群点。

Python 中的异常检测

离群点存在的原因

  • 数据录入错误:
    • 打字错误
    • 测量误差
    • 人为失误
    • 未修正则删除
  • 抽样错误:
    • 非目标分布
    • 删除
  • 自然:
    • 自然异常但来自总体
    • 不删除
Python 中的异常检测

按幅度删除

  • 太少:确认后删除
  • 太多:可疑——用不同模型:
    • GLM
    • 分位数回归
    • GEE
  • 形成簇:需深入分析
Python 中的异常检测

截尾

# Calculate the percentiles
percentile_first = google['Volume'].quantile(0.01)
percentile_99th = google['Volume'].quantile(0.99)


# Trim google['Volume'] = google['Volume'].clip(percentile_first, percentile_99th)
Python 中的异常检测

替换

google.replace(0, 100, inplace=True)
Python 中的异常检测

让我们练习!

Python 中的异常检测

Preparing Video For Download...