Question

Can anyone give me an example about how to use formula parameter when plot svm object.

I have the following R script

library(e1071)
dataset <- read.csv("train.svm", header=TRUE, sep = ",")
F <- factor(dataset$F)
C1 <- c(dataset$SC1)
C2 <- c(dataset$C2)
C3 <- c(dataset$C3)
C4 <- c(dataset$C4)
C5 <- c(dataset$C5)
C6 <- c(dataset$C6)

d = data.frame(F=F, C1=C1, C2=C2, C3=C3, C4=C4, C5=C5, C6=C6)
model = svm(F ~ C1 + C2 + C3 + C4 + C5 + C6, data = d)
summary(model)
plot(model, d, ??) #how to set formula ???**

Thanks,

Was it helpful?

Solution

This is from the documentation for plot.svm (http://cran.r-project.org/web/packages/e1071/e1071.pdf). A couple more examples can be found there as well. But the formula parameter just looks like it specifies the variables to vary over for a given plot. If you post your data or an example of it, we could maybe provide a more detailed solution.

m2 <- svm(Species~., data = iris)
plot(m2, iris, Petal.Width ~ Petal.Length,
     slice = list(Sepal.Width = 3, Sepal.Length = 4))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top