다양한 빈도 기준

R로 배우는 Bag-of-Words 텍스트 마이닝

Ted Kwartler

Instructor

용어 가중치

  • 기본 용어 빈도 = 단순 단어 수
  • 자주 쓰이는 단어가 통찰을 가릴 수 있음
  • TfIdf로 가중치 조정
  • 여러 문서에 자주 나오는 단어는 페널티 부여

단어 구름

R로 배우는 Bag-of-Words 텍스트 마이닝

용어 가중치

# 표준 용어 가중치
tf_tdm <- TermDocumentMatrix(text_corp)
tf_tdm_m <- as.matrix(tf_dtm)
tf_tdm_m[505:510, 5:10]

tdf.png

# TfIdf 가중치
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 텍스트 마이닝

문서 메타데이터 유지

# 처음 두 열이 doc_id와 text인지 확인
names(tweets)[1:2] <- c('doc_id','text')

# 메타데이터 포함 VCorpus 생성
test_corpus <- VCorpus(DataframeSource(tweets))
# 정제 후 결과 확인
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...