Graphic error, missing formula

I am trying to build my svm model.

library(foreign) library(e1071) x <- read.arff("contact-lenses.arff") #alt: x <- read.arff("http://storm.cis.fordham.edu/~gweiss/data-mining/weka-data/contact-lenses.arff") model <- svm(`contact-lenses` ~ . , data = x, type = "C-classification", kernel = "linear") 

The arff contact lens is an embedded data file in weka.

However, now I am facing an error trying to build a model.

  plot(model, x) Error in plot.svm(model, x) : missing formula. 
+7
r svm weka
source share
1 answer

The problem is that in your model you have several covariances. plot() will start automatically only if your data= argument has exactly three columns (one of which is the answer). For example, on the help page ?plot.svm 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 graph, you need to specify what you want to use for x and y when you have several choices 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 why are you getting the "Missing Formula" error.

There is another catch. plot.svm will only display continuous variables along the x and y axes. Contact lens data.fra data have only categorical variables. The plot.svm function simply does not support this, as far as I can tell. You will need to decide how you want to summarize this information in your own visualization.

+12
source share

All Articles