svm plot question
thanks, I did get this plot. Before I have this problem, I did get a plot by my code. However after I change a little my code. it doesn't work. It is pity not saving my original code. Now the question is the plot I get using your code is different from what I got before. Moreover I did remember I use plot(m.svm,p5.new,As~Cur) Do you know why? Thanks, Aimin
At 06:32 AM 12/8/2006, David Meyer wrote:
Aimin:
1) Please do not spam the r-help list---one request per issue (and two
private mails to the code author) really suffice. Not all contributors
to the R-project are on-line 24/24, and have time to provide immediate
answers.
2) The error occurs because plot.svm() currently does not set valid
defaults for categorical dimensions you are conditioning on for your
2D-plot (in your example: 'P' and 'Aa') which certainly is a bug. I will
commit a fix for the next release of e1071. For the time being, you will
have to explicitly specify the levels of 'P' and 'Aa':
plot(m.svm,p5.new,As~Cur, slice = list(P = factor("821p", levels =
levels(P)), Aa = factor("ALA", levels = levels(Aa))))
(Note that the defaults for the "slice" argument are completely
arbitrary anyway).
Thanks for pointing this out,
David
Aimin Yan wrote:
I have a question about svm in R
I run the following code, all other is ok,
but plot(m.svm,p5.new,As~Cur) is not ok
Do you know why?
install.packages("e1071")
library(e1071)
library(MASS)
p5 <- read.csv("http://www.public.iastate.edu/~aiminy/data/p_5_2.csv")
p5.new<-subset(p5,select=-Ms)
p5.new$Y<-factor(p5.new$Y)
levels(p5.new$Y) <- list(Out=c(1), In=c(0))
attach(p5.new)
m.svm<-svm(Y~P+Aa+As+Cur,data=p5.new)
summary(m.svm)
plot(m.svm,p5.new,As~Cur)
Here is output:
install.packages("e1071")
--- Please select a CRAN mirror for use in this session --- trying URL
Content type 'application/zip' length 592258 bytes
opened URL
downloaded 578Kb
package 'e1071' successfully unpacked and MD5 sums checked
The downloaded packages are in
C:\Documents and Settings\aiminy\Local
Settings\Temp\RtmpY0B2qb\downloaded_packages
updating HTML package descriptions
library(e1071)
Loading required package: class
library(MASS)
p5 <- read.csv("http://www.public.iastate.edu/~aiminy/data/p_5_2.csv")
p5.new<-subset(p5,select=-Ms)
p5.new$Y<-factor(p5.new$Y)
levels(p5.new$Y) <- list(Out=c(1), In=c(0))
attach(p5.new)
m.svm<-svm(Y~P+Aa+As+Cur,data=p5.new)
summary(m.svm)
Call:
svm(formula = Y ~ P + Aa + As + Cur, data = p5.new)
Parameters:
SVM-Type: C-classification
SVM-Kernel: radial
cost: 1
gamma: 0.04
Number of Support Vectors: 758
( 382 376 )
Number of Classes: 2
Levels:
Out In
plot(m.svm,p5.new,As~Cur)
Error in scale(newdata[, object$scaled, drop = FALSE], center =
object$x.scale$"scaled:center", :
(subscript) logical subscript too long
-- Dr. David Meyer Department of Information Systems and Operations Vienna University of Economics and Business Administration Augasse 2-6, A-1090 Wien, Austria, Europe Tel: +43-1-313 36 4393 Fax: +43-1-313 36 90 4393 HP: http://wi.wu-wien.ac.at/~meyer/