terms.BTM {BTM}R Documentation

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

Description

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

Usage

## 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


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)


[Package BTM version 0.3.6 Index]