Learn R Programming

SportMiner (version 0.1.0)

sm_train_lda: Train LDA Topic Model

Description

Fits a Latent Dirichlet Allocation (LDA) model to a document-term matrix.

Usage

sm_train_lda(
  dtm,
  k = NULL,
  method = "gibbs",
  seed = 1729,
  iter = 500,
  burnin = 100,
  alpha = NULL,
  beta = 0.1
)

Value

An LDA_Gibbs or LDA_VEM object from the topicmodels package.

Arguments

dtm

A DocumentTermMatrix object.

k

Number of topics. If NULL, will attempt to use sm_select_optimal_k first. Default is NULL.

method

Method for fitting. Options: "gibbs" or "vem". Default is "gibbs".

seed

Random seed for reproducibility. Default is 1729.

iter

Number of Gibbs iterations (if method = "gibbs"). Default is 500.

burnin

Number of burn-in iterations (if method = "gibbs"). Default is 100.

alpha

Hyperparameter for document-topic distributions. Default is 50/k (following Griffiths & Steyvers 2004).

beta

Hyperparameter for topic-word distributions. Default is 0.1.

Examples

Run this code
if (FALSE) {
# Requires document-term matrix from sm_create_dtm()
dtm <- sm_create_dtm(processed_data)
lda_model <- sm_train_lda(dtm, k = 10)
}

Run the code above in your browser using DataLab