我正在運行RTextTools包來構建文本分類模型。「RTextTools」create_matrix出錯
當我準備預測數據集,並試圖將其轉換爲矩陣。
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
錯誤 我試着搜索在谷歌,但沒有看到一個明確的解決方案。
感謝
構建測試項目的常用方法是使用'head'。一旦你有一個可重複的例子,首選的方法是使用'dput'來提供一個明確的例子。 –
感謝您的回答,如果您的意思是我只能用頭(幾個樣本)進行測試,那麼如何使用構建的模型來對剩餘數據進行分類?謝謝 –
我試圖促使你做的事情是發佈足夠的信息,我們可以提供幫助。只需發佈沒有數據的錯誤消息幾乎是不夠的。你需要自己做測試或者提供一個支持進一步調查的例子。 –