r - "RTextTools"create_matrix 出错

标签 r classification text-mining

我正在运行 RTextTools 包来构建文本分类模型。

当我准备预测数据集并尝试将其转换为矩阵时。我得到的错误是:

Error in if (attr(weighting, "Acronym") == "tf-idf") weight <- 1e-09 : 
  argument is of length zero

我的代码如下:
table<-read.csv("traintest.csv",header = TRUE)
dtMatrix <- create_matrix(table["COMMENTS"])
container <- create_container(dtMatrix, 
                              table$LIKELIHOOD_TO_RECOMMEND, 
                              trainSize=1:5000,testSize=5001:10000, 
                              virgin=FALSE)
model <- train_model(container, "SVM", kernel="linear", cost=1)

predictionData<-read.csv("rest.csv",header = TRUE)
**predMatrix <- create_matrix(predictionData["COMMENTS"],originalMatrix=dtMatrix)**
Error in if (attr(weighting, "Acronym") == "tf-idf") weight <- 1e-09 : 
      argument is of length zero

错误由最后一个代码给出(粗体)
我尝试在谷歌上搜索,但没有看到一个明确的解决方案。

谢谢

最佳答案

运行这个:

trace("create_matrix",edit=T)

在弹出的源代码框中,第 42 行中的“首字母缩略词”会拼错。将“A”更改为“a”并点击“保存” - 之后它应该可以正常工作。

关于r - "RTextTools"create_matrix 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32513513/

相关文章:

r - For 循环不使用 r 插入矩阵中的缺失值

基于Java的Word映射(语义)应用程序

python - 光GBM : validation AUC score during model fit differs from manual testing AUC score for same test set

r - 使用 R 获取 KNN 分类器的决策边界

python - 如何对未标记的数据进行分类?

python-3.x - Gensim doc2vecmost_similar相当于获取完整文档

python - 从 Python 中的非结构化文本中提取一个人的年龄

r - 如何使用 dplyr 熔化和类型转换数据框?

获取 ssl 端点时出现 RCurl 错误

r - 将文本 block 插入到 R 中特定行号的文件中