transport_weights | R Documentation |
An alignment based on transport weights sets the weight between topics k and
k' according to an optimal transport problem with (1) costs set by the
distance (specifically, Jensen-Shannon Divergence) between \beta_{k}
and \beta_{k^\prime}
and (2) masses defined by the total topic mixed
memberships \sum_{i}\gamma_{ik}
and \sum_{i}\gamma_{ik^\prime}
.
If topics have similar mixed membership weight and similar topic \beta
,
then they will be given high transport alignment weight.
transport_weights(gammas, betas, reg = 0.1, ...)
gammas |
(required) A list of length two, containing the mixed
membership matrices (a |
betas |
(required). A list of length two, containing the topic matrices
(a |
reg |
(optional) How much regularization to use in the Sinkhorn optimal transport algorithm? Defaults to 0.1. |
... |
(optional) Other keyword arguments. Not used here, but included for consistency with other weight functions. |
products A data.frame
giving the product similarity of each
pair of topics across the two input matrices.
library(purrr)
data <- rmultinom(10, 20, rep(0.1, 20))
lda_params <- setNames(map(1:5, ~ list(k = .)), 1:5)
lda_models <- run_lda_models(data, lda_params)
gammas <- list(lda_models[[3]]$gamma, lda_models[[5]]$gamma)
betas <- list(lda_models[[3]]$beta, lda_models[[5]]$beta)
transport_weights(gammas, betas)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.