Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"RTextTools" create_matrix got an error

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

like image 798
WayToNinja Avatar asked Sep 11 '15 00:09

WayToNinja


1 Answers

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.

like image 130
Eric O'Rourke Avatar answered Nov 02 '22 08:11

Eric O'Rourke