“ RTextTools” create_matrix出现错误 [英] "RTextTools" create_matrix got an error
本文介绍了“ RTextTools” create_matrix出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行RTextTools软件包来构建文本分类模型。
I was running RTextTools package to build a text classification model.
当我准备预测数据集并尝试将其转换为矩阵时。我收到错误消息:
And when I prepare the prediction dataset and tried to transform it in to matrix. I got error as:
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
错误由最后一个代码给出(粗体)
我尝试在Google上搜索,但没有找到一个明确的解决方案。
The error was given by the last code (bold) I tried search on google but didn't see one clear solution.
谢谢
推荐答案
运行此:
trace("create_matrix",edit=T)
在弹出的源代码框中,第42行将拼写错误的缩写。将 A更改为 a并点击保存-之后应该可以正常工作。
In the source code box that pops up, line 42 will have a misspelling of the word "acronym". Change the "A" to an "a" and hit "Save" - it should work fine after that.
这篇关于“ RTextTools” create_matrix出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文