term_score: Compute term-scores for each word-topic pair

Description Usage Arguments Value Examples

View source: R/helper-functions.R

Description

For more details, see Blei, D. M., & Lafferty, J. D. (2009). Topic models. In A. N. Srivastava & M. Sahami (Eds.), Text mining: Classification, clustering, and applications. Chapman and Hall/CRC.

Usage

1

Arguments

beta_

A K x V matrix of V vocabulary probabilities for each of K topics.

Value

A K x V matrix of term-scores (comparable to tf-idf).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#' library(lda) # Required if using `prep_docs()`

data(teacher_rate)  # Synthetic student ratings of instructors
docs_vocab <- prep_docs(teacher_rate, "doc")
vocab_len <- length(docs_vocab$vocab)
m1 <- gibbs_sldax(rating ~ I(grade - 1), m = 2,
                  data = teacher_rate, docs = docs_vocab$documents,
                  V = vocab_len, K = 2, model = "sldax")
hbeta <- est_beta(m1)
ts_beta <- term_score(hbeta)
# One row per topic, one column per unique term in the vocabulary
str(ts_beta)

ktw5691/psychtm documentation built on Nov. 3, 2021, 9:10 a.m.