Hello users! I'm calculating a simple model using svm(...) from the e1071 package. So far so good, with a linear kernel I'm getting 5 SVs. When plotting the result I see very well separated data clouds, but the underlying color is constantly pink, so as far as I understand no class separation is shown... I would be happy if anyone could explain me this behaviour because I think I have a little knot in my brain here... Thanks in advance! Greetings, Matthias -- View this message in context: http://r.789695.n4.nabble.com/Only-one-class-shown-in-SVM-plot-tp4637782.html Sent from the R help mailing list archive at Nabble.com.
Only one class shown in SVM plot?
6 messages · Meffy, Jessica Streicher
example!!!! but a wild guess: if your class information is numeric the default is to do eps-regression, not classification. Use factors or specify the type you want to use. ?svm might help there.
On 25.07.2012, at 15:31, Meffy wrote:
Hello users! I'm calculating a simple model using svm(...) from the e1071 package. So far so good, with a linear kernel I'm getting 5 SVs. When plotting the result I see very well separated data clouds, but the underlying color is constantly pink, so as far as I understand no class separation is shown... I would be happy if anyone could explain me this behaviour because I think I have a little knot in my brain here... Thanks in advance! Greetings, Matthias -- View this message in context: http://r.789695.n4.nabble.com/Only-one-class-shown-in-SVM-plot-tp4637782.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.
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.
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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120727/4ed1558c/attachment.pl>
4 days later
Thanks a lot! After thinking about it it definitely makes sense ! Greetings, Matthias -- View this message in context: http://r.789695.n4.nabble.com/Only-one-class-shown-in-SVM-plot-tp4637782p4638629.html Sent from the R help mailing list archive at Nabble.com.