Tweetlerde konu modelleme

R ile Sosyal Medya Verilerini Analiz Etme

Vivek Vijayaraghavan

Data Science Coach

Ders özeti

  • Konu modellemenin temelleri
  • Belge-terim matrisi (DTM) oluşturma
  • DTM’den konu modeli kurma
R ile Sosyal Medya Verilerini Analiz Etme

Konu ve Belge

Konu tanımı ve örnek

R ile Sosyal Medya Verilerini Analiz Etme

Konu ve Belge

Belge tanımı ve örnek

R ile Sosyal Medya Verilerini Analiz Etme

Konu modelleme

  • Konuları otomatik keşfetme görevi
  • Büyük veri kümelerinden çekirdek konuları çıkarın
  • Bilgiyi hızla konulara özetleyin
R ile Sosyal Medya Verilerini Analiz Etme

LDA nasıl çalışır

  • Konu modelleme için Latent Dirichlet Allocation (LDA)

LDA nasıl çalışır

R ile Sosyal Medya Verilerini Analiz Etme

LDA nasıl çalışır

LDA nasıl çalışır

R ile Sosyal Medya Verilerini Analiz Etme

LDA nasıl çalışır

LDA nasıl çalışır

R ile Sosyal Medya Verilerini Analiz Etme

Belge-terim matrisi (DTM)

  • Belge-terim matrisi (DTM) oluşturun
  • DTM, bir gövdenin matris gösterimidir
  • Belgeler satır, sözcükler/terimler sütundur

Belge-terim matrisi veya DTM

R ile Sosyal Medya Verilerini Analiz Etme

Belge-terim matrisi oluşturma

# Create a document term matrix
dtm <- DocumentTermMatrix(twt_corpus_refined)
R ile Sosyal Medya Verilerini Analiz Etme

Belge-terim matrisi oluşturma

# Inspect the DTM
inspect(dtm)
R ile Sosyal Medya Verilerini Analiz Etme

Belge-terim matrisi oluşturma

<<DocumentTermMatrix (documents: 1000, terms: 5079)>>
Non-/sparse entries: 12862/5066138
Sparsity           : 100%
Maximal term length: 29
Weighting          : term frequency (tf)
Sample             :
     Terms
Docs    california child diabetes fat food health people ranks rates weight
  131          0     0        0   0    0      0      0     0     0      0
  161          0     0        0   2    0      0      0     0     0      1
  295          0     0        0   0    1      0      1     0     0      0
  418          0     0        0   0    0      0      0     0     1      0
  604          0     0        1   0    0      1      0     0     0      0
R ile Sosyal Medya Verilerini Analiz Etme

DTM’yi hazırlama

  • Satır toplamı 0’dan büyük olan satırlar için DTM’yi filtreleyin
# Find the sum of word counts in each Document 
rowTotals <- apply(dtm , 1, sum)
# Select rows from DTM with row totals greater than zero
tweet_dtm_new <- dtm[rowTotals> 0, ]
R ile Sosyal Medya Verilerini Analiz Etme

Konu modelini kurun

  • LDA() işleviyle konu modelini oluşturun
# Build the topic model
library(topicmodels)
lda_5 <- LDA(tweet_dtm_new, k = 5)
R ile Sosyal Medya Verilerini Analiz Etme

Konu modelini kurun

  • Tweet gövdesinden 5 konu çıkarıldı
# View top 10 terms in the topic model
top_10terms <- terms(lda_5,10)
top_10terms
R ile Sosyal Medya Verilerini Analiz Etme

Modeldeki ilk 10 terimi görüntüleme

     Topic 1        Topic 2        Topic 3     Topic 4      Topic 5   
 [1,] "disease"      "people"       "black"     "child"      "weight"  
 [2,] "health"       "health"       "fat"       "rates"      "diet"    
 [3,] "cancer"       "diabetes"     "trump"     "ranks"      "food"    
 [4,] "meghanmccain" "overweight"   "childhood" "california" "diabetes"
 [5,] "realcandaceo" "fat"          "health"    "fat"        "health"  
 [6,] "food"         "meghanmccain" "professor" "eat"        "bmi"     
 [7,] "risk"         "realcandaceo" "gender"    "people"     "problem" 
 [8,] "heart"        "body"         "studies"   "epidemic"   "eating"  
 [9,] "weight"       "weight"       "healthy"   "health"     "disease" 
[10,] "diabetes"     "obese"        "problem"   "healthy"    "family"
  • Obezite yönetim programı, temasını bir çekirdek konu etrafında toplayabilir
R ile Sosyal Medya Verilerini Analiz Etme

Haydi pratik yapalım!

R ile Sosyal Medya Verilerini Analiz Etme

Preparing Video For Download...