I have a R matrix mat
and I want to perform LDA on it.
When I run lda_model$fit_transform(mat, n_iter = 20)
, I get an error:
Error in super$check_convert_input(x) :
don't know how to deal with input of class 'matrix'
Is there an easy way to solve this? The source for my matrix is not text and I don't want to go into vocabularies, itoken()
, etc.
Casting to sparseMatrix
before fitting the model seems to do the trick:
library(Matrix)
mat <- as(mat, "sparseMatrix")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.