这是我的数据:
Anon_Student_Id Problem_Hierarchy Problem_Name Problem_View Number_Of_Steps Sum_Of_Steps_Duration Sum_Of_Hints result 1 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG21 8 3 28 0 1 2 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG21 9 3 37 0 0 3 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG21 10 3 50 0 0 4 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG22 1 3 78 0 0 5 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG22 2 3 41 0 1 6 80nlN05JQ6 Unit ES_01, Section ES_01-6 EG22 3 3 92 0 0
我正在尝试使用SVM模型来预测属性“result”:
model<-svm(result~., scale=FALSE, data=W)
prediction <- predict(model, W[,-8])
table(pred = prediction, true = W[,8])
但是我得到了这个错误:
"Error in table(pred = prediction, true = W[, 8]) :
all arguments must have the same length"
当我检查时,输出的结果为:pred长度为2042,而true长度为2043。
为什么会出现这个错误?(也就是说,为什么pred和true的长度不同?它们应该具有相同的长度)
谢谢!
predict
函数应该会给出一个NA预测,但有可能是完全忽略了这种情况。请发布您用于拟合SVM的软件包。 - Hong Ooie1071
包。 - agstudy