-4

I a trying to apply SVM on my data in order to predict future data. So I have faced the following error:

All arguments must be the same length

> svmmodele1<-svm(data$note ~ AppCache+TCP+DNS,data=data,scale = FALSE,kernel="linear",cost= 0.08,gamma=0.06)
> svm.video.pred1<-predict(svmmodele1,data)
> svm.video.pred1
 1  3  4  5  6  7 10 11 12 13 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 
 3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3 
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 
 3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3  3 
Levels: 1 2 3 4 5
> svm.video.table1<-table(pred=svm.video.pred1, true= data$note)
Error in table(pred = svm.video.pred1, true = data$note) : 
  All arguments must be the same length

 data$note
 [1] 2 2 2 3 3 3 2 2 2 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 4 4 4 3 3 3 4 4 4 4 4 4 5 5
[39] 5 5 5 5 5 5 5 3 3 3 1 1 1 1 1 1
Levels: 1 2 3 4 5
Manel Chaabene
  • 187
  • 1
  • 3
  • 14
  • Show data$note too. – Chirayu Chamoli Aug 01 '16 at 12:49
  • 1
    The error is not related to `svm`. It's returned by `table` and pretty self-explaining. – Roland Aug 01 '16 at 12:50
  • 1
    @Roland it may be related to `svm.predict` someone else recently asked the same thing. http://stackoverflow.com/questions/38546899/my-rows-are-mismatched-in-my-svm-scripting-code-for-kaggle. The mismatched lengths may have revealed themselves in `table` but produced earlier. – Pierre L Aug 01 '16 at 12:52
  • please don not create images for the data. Provide the required input data directly as code format. [Check examples](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – user5249203 Aug 01 '16 at 13:12
  • I have edited my post @ChirayuChamoli – Manel Chaabene Aug 01 '16 at 14:00

1 Answers1

0

For who are stuck on the same problem, the reason of that error is that I have some negative variable.

Manel Chaabene
  • 187
  • 1
  • 3
  • 14