我测试了一个从 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("&", "", 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)