# NOT RUN {
<!-- %% @test .port Database port number -->
<!-- %% @test .dbname Database name -->
## set up the database connection
## Assume that .port is port number and .dbname is the database name
cid <- db.connect(port = .port, dbname = .dbname, verbose = FALSE)
dat <- db.data.frame("__madlib_pivotalr_lda_data__", conn.id = cid,
verbose = FALSE)
output.db <- madlib.lda(dat, 2,0.1,0.1, 50)
perplexity.db <- perplexity.lda.madlib(output.db)
print(perplexity.db)
## Run LDA multiple times and get the best one
output.db <- madlib.lda(dat, 2,0.1,0.1, 50, nstart=2)
perplexity.db <- perplexity.lda.madlib(output.db)
print(perplexity.db)
## Run LDA multiple times and keep all models
output.db <- madlib.lda(dat, 2,0.1,0.1, 50, nstart=2, best=FALSE)
perplexity.db <- perplexity.lda.madlib(output.db[[1]])
print(perplexity.db)
perplexity.db <- perplexity.lda.madlib(output.db[[2]])
print(perplexity.db)
db.disconnect(cid)
# }
Run the code above in your browser using DataLab