異なる頻度基準

Rで学ぶBag-of-Wordsによるテキストマイニング

Ted Kwartler

Instructor

用語の重み

  • 既定の出現頻度=単純な単語数
  • よく出る語が洞察を隠すことがある
  • TfIdfで重み付けを調整
  • 多くの文書に出る語は減点される

ワードクラウド2

Rで学ぶBag-of-Wordsによるテキストマイニング

用語の重み

# Standard term weighting
tf_tdm <- TermDocumentMatrix(text_corp)
tf_tdm_m <- as.matrix(tf_dtm)
tf_tdm_m[505:510, 5:10]

tdf.png

# TfIdf weighting
tf_idf_tdm <- TermDocumentMatrix(text_corp, 
    control = list(weighting = weightTfIdf))
tf_idf_tdm_m <- as.matrix(tf_idf_dtm)
tf_tdm_m <- as.matrix(tf_dtm)

tfidf.png

Rで学ぶBag-of-Wordsによるテキストマイニング

ドキュメントのメタデータを保持する

# Ensure the first 2 columns are doc_id & text
names(tweets)[1:2] <- c('doc_id','text')

# Create VCorpus including metadata
test_corpus <- VCorpus(DataframeSource(tweets))
# Clean and view results
text_corpus <- clean_corpus(text_corpus)
content(text_corpus[[1]])
$content
[1] "ayyytylerb true drink lots coffee"
meta(text_corpus[[1]])
$meta
  id      : 1
  author  : thejennagibson
  date    : 8/9/2013 2:43
  language: en
Rで学ぶBag-of-Wordsによるテキストマイニング

練習しましょう!

Rで学ぶBag-of-Wordsによるテキストマイニング

Preparing Video For Download...