将R矩阵转换为text2vec dtm

问题描述 投票:0回答:1

我有一个R矩阵mat,我想在它上面执行LDA。

当我运行lda_model$fit_transform(mat, n_iter = 20)时,我收到一个错误:

Error in super$check_convert_input(x) : 
 don't know how to deal with input of class 'matrix'

有没有简单的方法来解决这个问题?我的矩阵的来源不是文本,我不想进入词汇表,itoken()等。

r text-mining text2vec
1个回答
0
投票

在拟合模型之前投射到sparseMatrix似乎可以解决问题:

library(Matrix)
mat <- as(mat, "sparseMatrix")
© www.soinside.com 2019 - 2024. All rights reserved.