不正に対するトピックモデル

Pythonで学ぶ不正検知

Charlotte Werger

Data Scientist

トピックモデル: テキストの隠れたパターンを発見

  1. 文章データからトピックを発見
  2. 「このテキストは何についてか」を把握
  3. 概念的にはクラスタリングに類似
  4. 不正と非不正のトピックを比較し、特徴量やフラグに利用
  5. または、特定のトピックが不正を示唆していないか確認
Pythonで学ぶ不正検知

Latent Dirichlet Allocation (LDA)

LDAで得られるもの:

  1. 「テキストごとのトピック」モデル(確率)
  2. 「トピックごとの単語」モデル

独自のトピックモデルを作成:

  1. データをクレンジング
  2. 辞書とコーパスでBag-of-Wordsを作成
  3. 辞書とコーパスをLDAに投入
Pythonで学ぶ不正検知

Latent Dirichlet Allocation (LDA)

Pythonで学ぶ不正検知

Bag of Words: 辞書とコーパス

from gensim import corpora
# 単語の出現回数に基づく辞書を作成
dictionary = corpora.Dictionary(cleaned_emails)
# 出現頻度が(非)極端な単語を除外 
dictionary.filter_extremes(no_below=5, keep_n=50000)
# コーパスを作成
corpus = [dictionary.doc2bow(text) for text in cleaned_emails]
Pythonで学ぶ不正検知

gensimでのLatent Dirichlet Allocation (LDA)

import gensim
# LDAモデルを定義
ldamodel = gensim.models.ldamodel.LdaModel(corpus, num_topics = 3, 
id2word=dictionary, passes=15)
# 上位語を含む3つのトピックを表示
topics = ldamodel.print_topics(num_words=4)
for topic in topics:
    print(topic)
(0, 0.029*"email" + 0.016*"send" + 0.016*"results" + 0.016*"invoice")
(1, 0.026*"price" + 0.026*"work" + 0.026*"management" + 0.026*"sell")
(2, 0.029*"distribute" + 0.029*"contact" + 0.016*"supply" + 0.016*"fast")
Pythonで学ぶ不正検知

演習に進みましょう!

Pythonで学ぶ不正検知

Preparing Video For Download...