1

I'm trying to do 1D SVM plotting using e1071 package in R.

I am new to this so I not sure whether the issue is that the e1071 package do not support 1D plotting (since I could not locate any 1D plotting information here: http://www.inside-r.org/node/57517, http://www.inside-r.org/packages/cran/e1071/docs/plot.svm) or there is something wrong with my formula here.

library(e1071)
data<-iris[,4:5]
#using subset of iris as data with Species as label
model<-svm(Species~.,data)

plot(model,data)
Error in plot.svm(model, data) : missing formula.

plot(model,data,Petal.Width~.)
Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,  : min not meaningful for factors

Thank you.

Update

I saw this answer which is saying that the 1D plotting is not supported in e1071. Since this answer is posted years ago, I wonder whether the 1D plotting is still not supported now.

Community
  • 1
  • 1
Ivan
  • 163
  • 1
  • 3
  • 15
  • 1
    It is a plotting problem, not a classification one. –  Oct 07 '15 at 01:44
  • What exactly do you expect the plot to look like in the 1-D case? What exactly is the output you are after here? – MrFlick Oct 07 '15 at 03:06
  • @MrFlick I expecting the plot to look something like this [plot](http://1.bp.blogspot.com/-xLBj8-EvWdU/UNuDyX2K75I/AAAAAAAAAMY/Eg7Labb03zk/s1600/kernel_trick1.png) – Ivan Oct 07 '15 at 03:14

1 Answers1

2

If this is really just about plotting, that's handled by ?plot.svm if you pass an svm object as the first parameter. That function does not support 1D plots.

You can create your own with something like

plot(model.frame(model)[,2], col=predict(model))

enter image description here

MrFlick
  • 195,160
  • 17
  • 277
  • 295