R编程错误用于预测,并且错误为predict.svm:测试数据与模型不匹配

时间:2019-05-24 09:50:02

标签: r machine-learning maxent

我测试了uI提供的新数据,因此我使用了new.csv文件,该文件具有与训练模型相同的列名。

这是什么问题?

此行classify_models(container2,maxent_model)

中出现错误
load("maxent.rda")
new = read_csv("new.csv")
new$data <- paste(new$Title,new$Body)
new$data = as.character(new$data)
new$data = as.character(new$data)
new$data[nrow(new)] = as.character(input$caption)
new$data = toupper(new$data)
new$data = gsub("<.*?>", "", as.character(new$data))
new$data = gsub("&amp", "", new$data)
new$data = gsub("(RT|via)((?:\\b\\W*@\\w+)+)", "", new$data)
new$data = gsub("@\\w+", "", new$data)
new$data = gsub("[[:punct:]]", "", new$data)
new$data = gsub("[[:digit:]]", "", new$data)
new$data = gsub("http\\w+", "", new$data)
new$data = gsub("[ \t]{2,}", "", new$data)
new$data = gsub("^\\s+|\\s+$", "", new$data)
#write.csv(new, "new_data1.csv", row.names = FALSE)
matrix2 <- create_matrix(new["data"], language="english", 
    weighting=tm::weightTfIdf)
container2 <- create_container(matrix2, new$TagId, trainSize=NULL, 
                               testSize=1:nrow(new), virgin=TRUE)
maxent_results2 <- classify_models(container2,maxent_model)
mydata = data.frame(new,maxent_results2)

0 个答案:

没有答案