Dear all, I'm not able to solve easily the following simple problem. I really hope someone can give me some hints. I trained an svm (e1071). Now I'd like to show the results graphically. I used plot.svm and I'd like to add some other objects to the plot: points, (coloured) ellipses to indicate some intersting regions, curves, and so on... I tried to pass these as additional graphics parameters to pass to filled.contour, as indicated in ?plot.svm and in examples in filled.contour help. But it doesn't seem to work. Where is my foult? Can anyone help me? Best, Alessandro PS: I use R 1.9.0 on a WinXP OS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Alessandro Ambrosi, Ph.D. | Oncological Surgical Sc. Dept. | mail: ale.ambrosi at unipd.it Surg. Cl. II | ambrosi at stat.unipd.it University of Padua | fax: +39 049 651891 via Giustiniani, 2 | tel: +39 049 8212055 I-35128 Padua (ITALY) | url: www.stat.unipd.it/~ambrosi ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ------------------------------------------------- This mail sent through IMP: webmail.unipd.it
You probably won't be able to do that without modifying plot.svm(). It
calls filled.contour() like this:
filled.contour(xr, yr, matrix(as.numeric(preds),
nr = length(xr), byrow = TRUE), plot.axes = {
axis(1)
axis(2)
colors <- as.numeric(model.response(model.frame(x,
data)))
points(formula, data = data[-x$index, ], col colors[-x$index])
points(formula, data = data[x$index, ], pch = "x",
col = colors[x$index])
}, levels = 1:(length(unique(as.numeric(preds))) +
1), key.axes = axis(4, 1:length(unique(as.numeric(preds))) +
0.5, labels = levels(preds)[unique(preds)], las = 3),
plot.title = title(main = "SVM classification plot",
xlab = names(lis)[2], ylab = names(lis)[1]),
...)
Note the elaborate `plot.axes=' argument. You can try add another argument
to plot.svm, which takes an plotting expression, then plug that expression
to the end of the `plot.axes=' expression shown above.
[Note to David: There's a typo in ?plot.svm (spelling for `vector').]
HTH,
Andy
> From: ale.ambrosi at unipd.it
>
> Dear all,
>
> I'm not able to solve easily the following simple problem.
> I really hope someone can give me some hints.
>
> I trained an svm (e1071). Now I'd like to show the results
> graphically.
> I used plot.svm and I'd like to add some other objects to the plot:
> points, (coloured) ellipses to indicate some intersting
> regions, curves,
> and so on...
> I tried to pass these as additional graphics parameters to pass to
> filled.contour, as indicated in ?plot.svm and in examples in
> filled.contour help.
>
> But it doesn't seem to work.
>
> Where is my foult? Can anyone help me?
>
> Best,
> Alessandro
>
>
> PS: I use R 1.9.0 on a WinXP OS
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Alessandro Ambrosi, Ph.D. |
> Oncological Surgical Sc. Dept. | mail: ale.ambrosi at unipd.it
> Surg. Cl. II | ambrosi at stat.unipd.it
> University of Padua | fax: +39 049 651891
> via Giustiniani, 2 | tel: +39 049 8212055
> I-35128 Padua (ITALY) | url:
> www.stat.unipd.it/~ambrosi
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> -------------------------------------------------
> This mail sent through IMP: webmail.unipd.it
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
Hi all, First of all thanks for the answers. I'd like to add some objects to a plot.svm graphic. To give a more precise idea here I make a simple example. First I train a SVM.> m.svm <- svm(status~., data = dati.svm,kernel="radial", cross=20, scale=TRUE ) Then I generates a scatter plot of a svm fit:> plot.svm(m.svm, data=dati.svm, v.1 ~ v.2, slice = list(...),grid = 100) This works well. Now I have several data frames of points relatives to different samples, say dati.1, dati.2,... (of course of the same kind of dati.svm). I'd like to add them to the plot, each with different symbol and their (elliptic) hull. How can I do it? BTW: Are there any way to reppresent the model giving (the idea of) a third dimension? Thanks, Alessandro ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Alessandro Ambrosi, Ph.D. | Oncological Surgical Sc. Dept. | mail: ale.ambrosi at unipd.it Surg. Cl. II | ambrosi at stat.unipd.it University of Padua | fax: +39 049 651891 via Giustiniani, 2 | tel: +39 049 8212055 I-35128 Padua (ITALY) | url: www.stat.unipd.it/~ambrosi ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ------------------------------------------------- This mail sent through IMP: webmail.unipd.it