
122
■
6
章 トピックモデリング
6.2.3
単語ごとの分類:
augment
LDA
アルゴリズムには、各文書の個々の単語をトピックに分類するステップがあ
ります。一般に、文書内に特定のトピックに分類される単語が多ければ多いほど、
文書
-
トピック分類の重み(
gamma
)は大きくなるはずです。
もとの文書
-
単語のペアに戻り、各文書のどの単語がどのトピックに分類される
のかを調べてみたいところです。これは、
augment()
関数の仕事です。
augment()
も、
モデル出力の整理の方法として
broom
パッケージが導入した関数です。
tidy()
がモ
デルの統計部分を取り出すのに対し、
augment()
はモデルを使って、もとのデータ
の観測値に情報を付加します。
assignments <- augment(chapters_lda, data = chapters_dtm)
assignments
## # A tibble: 104,722
×
4
#
# document term count .topic
## <chr> <chr> <dbl> <dbl>
## 1 Great Expectations_57 joe 88 4
## 2 Great Expectations_7 joe 70 4
## 3 Great Expectations_17 joe 5 4
## 4 Great Expectations_27 joe 58 4
## 5 Great Expectations_2 joe 56 4
## ...