terms.BTM: Get highest token probabilities for each topic or get biterms...

Description Usage Arguments Value See Also Examples

View source: R/btm.R

Description

Get highest token probabilities for each topic or get biterms used in the model

Usage

1
2
## S3 method for class 'BTM'
terms(x, type = c("tokens", "biterms"), threshold = 0, top_n = 5, ...)

Arguments

x

an object of class BTM as returned by BTM

type

a character string, either 'tokens' or 'biterms'. Defaults to 'tokens'.

threshold

threshold in 0-1 range. Only the terms which are more likely than the threshold are returned for each topic. Only used in case type = 'tokens'.

top_n

integer indicating to return the top n tokens for each topic only. Only used in case type = 'tokens'.

...

not used

Value

Depending if type is set to 'tokens' or 'biterms' the following is returned:

See Also

BTM, predict.BTM, logLik.BTM

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(udpipe)
data("brussels_reviews_anno", package = "udpipe")
x <- subset(brussels_reviews_anno, language == "nl")
x <- subset(x, xpos %in% c("NN", "NNP", "NNS"))
x <- x[, c("doc_id", "lemma")]
model  <- BTM(x, k = 5, iter = 5, trace = TRUE)
terms(model)
terms(model, top_n = 10)
terms(model, threshold = 0.01, top_n = +Inf)
bi <- terms(model, type = "biterms")
str(bi)

BTM documentation built on July 2, 2021, 5:06 p.m.