Dear R people, I am trying to plot the results from running svm in library(e1071). I use plot.svm. After searching through the help archives and FAQ, I still have several questions: 1. In default, crosses indicate support vectors. But why are there two colors of crosses? What do they represent? 2. I want to draw a white-gray colored plot and modify the different colored crosses or circles by different shaped points. Could anyone give me a hint? 3. Is it possible for me to draw a "hyperplane" on the plot? 4. What is the algorithm to plot the contour region? Thank you very much, Frank
David can give the definitive answers, but I'll give my take on this...> From: Frank Duan > > Dear R people, > > I am trying to plot the results from running svm in library(e1071). I > use plot.svm. After searching through the help archives and FAQ, I > still have several questions: > > 1. In default, crosses indicate support vectors. But why are there > two colors of crosses? What do they represent?SVs are part of the training data, and as such, have class labels, right?> 2. I want to draw a white-gray colored plot and modify the different > colored crosses or circles by different shaped points. Could anyone > give me a hint?Supposedly possible with the ... argument, but it's not clear how to do that, unless you read the code (which you can, of course). Looks like some graphical parameters are hardwired in there, so you might need to modify it to your own liking.> 3. Is it possible for me to draw a "hyperplane" on the plot?Not sure what you mean. You are looking at a 2D subspace. How do you want to draw hyperplane on such subspace?> 4. What is the algorithm to plot the contour region?Again, you can look at the code. It does the logical thing: predict() on a regular grid and plot that. Andy> Thank you very much, > > Frank > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
Frank:> Dear R people,> I am trying to plot the results from running svm in library(e1071). I > use plot.svm. After searching through the help archives and FAQ, I > still have several questions:> 1. In default, crosses indicate support vectors. But why are there > two colors of crosses? What do they represent?The colors represent the classes of the data points. The help page admittedly doesn't tell you this and deserves improvement.> 2. I want to draw a white-gray colored plot and modify the different > colored crosses or circles by different shaped points. Could anyone > give me a hint?I just added three arguments to plot.svm() that allow customizing of the plot symbols. The contour region is controlled by the parameters of the filled.contour() function used in plot.svm(), so you will need to add the color.palette argument to plot.svm (which subsequently will be passed to filled.contour()).> 3. Is it possible for me to draw a "hyperplane" on the plot?You can add arbitrary objects to the plot (try lines()); but plot.svm() doesn't compute the boundaries.> 4. What is the algorithm to plot the contour region?see filled.contour(). The input is determined by a grid of predicted values. Best, -d> Thank you very much,> Frank-- Dr. David Meyer Department of Information Systems Vienna University of Economics and Business Administration Augasse 2-6, A-1090 Wien, Austria, Europe Fax: +43-1-313 36x746 Tel: +43-1-313 36x4393 HP: http://wi.wu-wien.ac.at/~meyer/
> I updated the e1071 package but still can't find > the other three arguments for plot.svm.It's in e1071 since version 1.5-3. (current version: 1.5-4).> In addition, I can plot a > gray-colored contour region by adding the argument "col = c(gray(0.2), > gray(0.8))". But I failed to change those colored "x" or "o" points > into the shapes I want. Basically, I don't want to have any color in > the plot. Could you give me a hint how to do that?Look at the example on the help page for plot.svm(). Best, David.