I am trying to plot my svm model.
library(foreign)
library(e1071)
x <- read.arff(\"contact-lenses.arff\")
#alt: x <- read.arff(\"http://storm.cis.ford
The problem is that in in your model, you have multiple covariates. The plot()
will only run automatically if your data=
argument has exactly three columns (one of which is a response). For example, in the ?plot.svm
help page, you can call
data(cats, package = "MASS")
m1 <- svm(Sex~., data = cats)
plot(m1, cats)
So since you can only show two dimensions on a plot, you need to specify what you want to use for x
and y
when you have more than one to choose from
cplus<-cats
cplus$Oth<-rnorm(nrow(cplus))
m2 <- svm(Sex~., data = cplus)
plot(m2, cplus) #error
plot(m2, cplus, Bwt~Hwt) #Ok
plot(m2, cplus, Hwt~Oth) #Ok
So that's why you're getting the "Missing Formula" error.
There is another catch as well. The plot.svm
will only plot continuous variables along the x
and y
axes. The contact-lenses data.frame has only categorical variables. The plot.svm
function simply does not support this as far as I can tell. You'll have to decide how you want to summarize that information in your own visualization.