Skip to content

Performance decrease in dfm_group #1295

Description

@HolgersID

Hi,
thank you for this great package! I used it successfully to demonstrate what can be achieved by textmining and what not.

Between versions v1.0.0 and v1.1.0 I observed a strong decrease of performance of function dfm_group. For the example below and version v1.0.0 a grouping took on my system

system.time (dfm_group (tdfm, "Group"))
##    user  system elapsed
##    1.59    0.31    1.92

With v1.1.0 this changed to

system.time (dfm_group (tdfm, "Group"))
##    user  system elapsed
##   95.66    0.37   96.24

Astonishingly, this seems to depend on the fact that the DFM contains an additional document level variable FGroup of type factor. If this is removed, dfm_group will be fast again:

docvars (tdfm, "FGroup") <- NULL
system.time (dfm_group (tdfm, "Group"))
##    user  system elapsed
##    1.71    0.37    2.09

The DFM of the test data set consists of 100000 documents, 15600 features, and has a sparsity of 99.7%. The document level variable Group has approx. 73000 different values.

Example data:

set.seed (4711)
no <- 100000L
tdata <-
    data.frame (ID=     as.character (seq.int (no))
              , Group=  sample (seq.int (1.5*no)
                              , no
                              , replace=TRUE
                                )
              , FGroup= factor (sample (seq.int (20L)
                                      , no
                                      , replace=TRUE
                                        )
                                )
              , Text=   replicate (no
                                 , paste (replicate (50L
                                                   , paste (sample (LETTERS
                                                                  , 3
                                                                    )
                                                          , collapse=""
                                                            )
                                                     )
                                        , collapse=" "
                                          )
                                   )
              , stringsAsFactors= FALSE
                )
tdfm <-
    dfm (corpus (tdata
               , docid_field= "ID"
               , text_field=  "Text"
                 )
         )

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions