calc_lambda: Calculate a matrix whose rows represent P(topic_i|tokens)

View source: R/utils.R

calc_lambdaR Documentation

Calculate a matrix whose rows represent P(topic_i|tokens)

Description

Use Bayes' rule to get P(topic|token) from the estimated parameters of a probabilistic topic model.This resulting "lambda" matrix can be used for classifying new documents in a frequentist context and supports augment.

Usage

calc_lambda(beta, theta, p_docs = NULL, correct = TRUE)

Arguments

beta

a beta matrix

theta

a theta matrix

p_docs

A numeric vector of length nrow(theta) that is proportional to the number of terms in each document, defaults to NULL.

correct

Logical. Do you want to set NAs or NaNs in the final result to zero? Useful when hitting computational underflow. Defaults to TRUE. Set to FALSE for troubleshooting or diagnostics.

Value

Returns a matrix whose rows correspond to topics and whose columns correspond to tokens. The i,j entry corresponds to P(topic_i|token_j)


tidylda documentation built on July 26, 2023, 5:34 p.m.