外れ値への対処法

Anomaly Detection in Python

Bekhruz (Bex) Tuychiev

Kaggle Master, Data Science Content Creator

異常検知の適用分野

  • 医療
  • サイバーセキュリティ
  • 不正検知

外れ値あり・なしの2通りで分析する。

Anomaly Detection in Python

外れ値が存在する理由

  • データ入力エラー:
    • タイプミス
    • 測定誤差
    • 人為ミス
    • 修正できないなら削除
  • サンプリング誤差:
    • 目的の分布から外れている
    • 削除
  • 自然由来:
    • 母集団に属するが珍しい
    • 削除しない
Anomaly Detection in Python

大きさに基づく削除

  • ごく少数: 確認して削除
  • 多すぎる: 要注意 ― 別のモデルを使用:
    • GLM
    • 分位点回帰
    • GEE
  • クラスター形成: 追加分析を実施
Anomaly Detection in 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)
Anomaly Detection in Python

置換

google.replace(0, 100, inplace=True)
Anomaly Detection in Python

演習に進みましょう

Anomaly Detection in Python

Preparing Video For Download...