Test: quanteda::textmodel-ca

To test the performance of calculation applying on dense dfm matrix versus on sparse dfm matrix (with truncated svd).

require(quanteda, quietly = TRUE, warn.conflicts = FALSE)
ie2010dfm <- dfm(data_corpus_irishbudget2010, verbose = FALSE)

ie2010dfm_dense <- as.matrix(ie2010dfm)

microbenchmark::microbenchmark(
    ca = ca::ca(ie2010dfm_dense), 
    ca_textmodel = textmodel_ca(ie2010dfm),
    times = 10, unit = 'relative')
data(SOTUCorpus, package = "quantedaData")
SOTUdfm <- dfm(SOTUCorpus)
SOTUdfm_dense <- as.matrix(SOTUdfm)
microbenchmark::microbenchmark(
    ca = ca::ca(SOTUdfm_dense), 
    ca_textmodel = textmodel_ca(SOTUdfm),
    times = 10, unit = 'relative')
load("/home/kohei/Documents/Brexit/Analysis/data_dfm_guardian.RData")
ndoc(data_dfm_guardian)
gud_ca <- textmodel_ca(data_dfm_guardian[1:10000], sparse = TRUE, residual_floor = 0.1)
summary(gud_ca)


quanteda/quanteda documentation built on April 15, 2024, 7:59 a.m.