Only one class shown in SVM plot?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Only one class shown in SVM plot?

Meffy
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Only one class shown in SVM plot?

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.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Only one class shown in SVM plot?

Meffy
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Only one class shown in SVM plot?

Jessica Streicher
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.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Only one class shown in SVM plot?

Jessica Streicher
Found it depends on what you put in in slice, since you have to define at what constant the other variables should be held.

sl<-list(V3=17,V4=14,V5=4,V6=0.5,V7=26,V8=10,V9=15,V10=0,V11=0.4,V12=0.3,V13=1.2,V14=2.3,V15=4.2,V16=5.2,V17=5.1,V18=4.3,V19=3.35)
> plot(model,data,V1~V2,slice=sl)

For example will let you view a bit of that separating plane.  I'm not getting creative on how to find the best values there though..

On 27.07.2012, at 10:21, Jessica Streicher wrote:

> 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.
>>
>> ______________________________________________
>> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Only one class shown in SVM plot?

Meffy
CONTENTS DELETED
The author has deleted this message.