this is my data:
这是我的数据:
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
I'm trying to predict the attribute "result" by SVM model :
我试图通过SVM模型来预测“结果”的属性:
model<-svm(result~., scale=FALSE, data=W)
< svm模型(结果~。、规模= FALSE,data = W)
prediction <- predict(model, W[,-8])
< -预测预测(模型、W[8])
table(pred = prediction, true = W[,8])
表(pred =预测,true = W[,8])
But I get this error:
但是我得到了这个错误:
"Error in table(pred = prediction, true = W[, 8]) :
all arguments must have the same length"
When I checked it I got: length(pred)=2042 and length(true)=2043
当我检查时,我得到:长度(pred)=2042,长度(true)=2043。
Why I'm getting this error?? (I mean- why i'm getting different lengths? "pred" and "true" are supposed to have the same length)
为什么会有这个错误??(我的意思是,为什么我有不同的长度?"pred"和"true"应该有相同的长度
Thanks!
谢谢!
1 个解决方案
#1
4
Problem solved: i got rid of all the na values of my data using na.omit(W) and then it worked. thank you!
问题解决了:我使用na.省略(W)去掉了所有数据的na值,然后就成功了。谢谢你!
#1
4
Problem solved: i got rid of all the na values of my data using na.omit(W) and then it worked. thank you!
问题解决了:我使用na.省略(W)去掉了所有数据的na值,然后就成功了。谢谢你!