“RTextTools” create_matrix got an error

冷暖自知 提交于 2019-12-03 12:04:35

问题


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

My code is as below:

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

The error was given by the last code (bold) I tried search on google but didn't see one clear solution.

Thanks


回答1:


Run this:

trace("create_matrix",edit=T)

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.



来源:https://stackoverflow.com/questions/32513513/rtexttools-create-matrix-got-an-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!