[R] Only one class shown in SVM plot?
Jessica Streicher
j.streicher at micromata.de
Fri Jul 27 10:21:59 CEST 2012
Now i'm scratching my head as well, thought it might have to do with scaling at first, so i turned it off, and also tried scaling the data for the plot instead, but to no avail, it just switches the color, but doesn't show the correct contours.
And it is at least predicting the stuff right, so its doesn't seem to be a problem with the model.
On 26.07.2012, at 15:00, Meffy wrote:
> Ok, here a simple example. The file
> http://r.789695.n4.nabble.com/file/n4637924/test.csv test.csv has 400 lines
> containing 20 columns (1. column is class label, the other 19 are the
> features).
> So what I'm doing is
> /
> data <- read.csv(file="test.csv", head=F, sep=",")
>
> names(data) <- c("Class","V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8",
> "V9", "V10", "V11", "V12", "V13", "V14", "V15", "V16", "V17", "V18", "V19")
>
> model <- svm(as.factor(Class)~., data=data, kernel="linear")
> /
>
> This gives me the result
>
> /
> Parameters:
> SVM-Type: C-classification
> SVM-Kernel: linear
> cost: 1
> gamma: 0.05263158
>
> Number of Support Vectors: 5
> /
> When plotting this with
>
> /
> plot(model, data, V2~V1)
> /
>
> I'm getting
> http://r.789695.n4.nabble.com/file/n4637924/svm_result.png
> Where am I wrong here??
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Only-one-class-shown-in-SVM-plot-tp4637782p4637924.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list