quanteda / quanteda.textmodels

Text scaling and classification models for quanteda
42 stars 6 forks source link

predict errors for textmodel_lsa(dfmt, margin = "features") #54

Open koheiw opened 2 years ago

koheiw commented 2 years ago
require(quanteda)
#> Loading required package: quanteda
#> Warning in .recacheSubclasses(def@className, def, env): undefined subclass
#> "packedMatrix" of class "replValueSp"; definition not updated
#> Warning in .recacheSubclasses(def@className, def, env): undefined subclass
#> "packedMatrix" of class "mMatrix"; definition not updated
#> Package version: 3.2.1
#> Unicode version: 13.0
#> ICU version: 69.1
#> Parallel computing: 8 of 8 threads used.
#> See https://quanteda.io for tutorials and examples.
require(quanteda.textmodels)
#> Loading required package: quanteda.textmodels

toks <- tokens(data_corpus_inaugural)
dfmt <- dfm(toks)

lsa1 <- textmodel_lsa(dfmt, margin = "document")
pred1 <- predict(lsa1)

lsa2 <- textmodel_lsa(dfmt, margin = "features")
pred2 <- predict(lsa2)
#> Error in newdata %*% object$features: not-yet-implemented method for <dgCMatrix> %*% <NULL>

Created on 2022-05-20 by the reprex package (v2.0.1)

I think $features should be $docs for margin = "features".

https://github.com/quanteda/quanteda.textmodels/blob/17f1c84f6b5fd3c063c2389e3259e907bacc3957/R/textmodel_lsa.R#L123