5
votes

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 :

model<-svm(result~., scale=FALSE, data=W)

prediction <- predict(model, W[,-8])

table(pred = prediction, 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

Why I'm getting this error?? (I mean- why i'm getting different lengths? "pred" and "true" are supposed to have the same length)

Thanks!

1
Maybe I miss something but 2042 != 2043, isn't it?agstudy
of course but why i'm getting different lengths?Mariel
@agstudy obviously 2042 == 2043, to within a margin of error. @OP: you might have an NA somewhere in your dataset. The predict function should give an NA prediction, but it's possible it's just dropping that case entirely. Post the package you're using to fit the SVM.Hong Ooi
@HongOoi :) good point! I guess it is e1071 package.agstudy
yes, i'm using e1071 package.Mariel

1 Answers

5
votes

Problem solved: i got rid of all the na values of my data using na.omit(W) and then it worked. thank you!