Hi,

Please don't forget to copy R-help on your reply - other people are

likely to have more insight.

My understanding is that you want to replicate the shaded polygons

produced by plot.svm on your own plot. That's why I suggested you

first try add=TRUE, and if that doesn't work, then look at the code

for plot.svm so you can see how the predicted values are calculated on

a grid to be plotted. R is open source - you can extract the section

from that function that does what you want, and make your own code to

add it to another plot.

I have no idea what "the tutorial" is; I suggested two things you

could try based on the help and my understanding of R.

Sarah

On Thu, Dec 20, 2018 at 9:07 AM Luigi Marongiu <

[hidden email]> wrote:

>

> Dear Sarah,

> I have looked at the tutorial but I did not find what I was looking

> for. Essentially, I would like to extract the data that make the

> hyperplane (it should be a matrix of X,Y value, for a bidimensional

> plane, I guess) so I can plot a line in another plot. I tried with

> model$SV but it is not the right one.

> Luigi

>

> On Thu, Dec 20, 2018 at 2:59 PM Sarah Goslee <

[hidden email]> wrote:

> >

> > Hi,

> >

> > According to the help for svm, which you probably should have started

> > with, SV contains the support vectors, and index contains the position

> > of the support vectors in the data matrix.

> >

> > As for plotting, plot.svm lets you pass additional options to plot so

> > that you can customize the plot to your tastes. I'm not sure if

> > add=TRUE is a useful option there, but you should try it. If that

> > doesn't meet your needs, R is open source - you can easily look at the

> > code for plot.svm and see what you need (basically the predicted

> > values on agrid, if I'm understanding your goal correctly).

> >

> > Sarah

> >

> > On Thu, Dec 20, 2018 at 5:16 AM Luigi Marongiu <

[hidden email]> wrote:

> > >

> > > Dear all,

> > > I am using the package e1071 for modeling SVM. I obtain a model from

> > > the data and I can plot the results; the plot shows the support

> > > vectors (as 'X's) and the shaded areas as it should be.

> > > However, I don't like the plot generated from the model and I would

> > > like instead to have more control upon the plotting; in particular, I

> > > would like to draw the hyperplane on plots I have already made from

> > > the data available.

> > > Is there a way to extract the values that are used to draw the hyperplane?

> > > That is: plot(model) -- where model is obtained from svm() -- draws an

> > > area in blue and one in red based on some values provided by model;

> > > can I get these values so I can plot a line in a pre-existing plot?

> > > Also, it is possible to extract the positions of the support vectors?

> > > The names of the model generated by svm() are:

> > > > names(mod)

> > > [1] "call" "type" "kernel" "cost"

> > > [5] "degree" "gamma" "coef0" "nu"

> > > [9] "epsilon" "sparse" "scaled" "x.scale"

> > > [13] "y.scale" "nclasses" "levels" "tot.nSV"

> > > [17] "nSV" "labels" "SV" "index"

> > > [21] "rho" "compprob" "probA" "probB"

> > > [25] "sigma" "coefs" "na.action" "fitted"

> > > [29] "decision.values" "terms"

> > >

> > > Which one should I look at?

> > > Thank you

> > > --

> > > Best regards,

> > > Luigi

> > >

--

Sarah Goslee (she/her)

http://www.numberwright.com______________________________________________

[hidden email] mailing list -- To UNSUBSCRIBE and more, see

https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide

http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.