I'm trying to add single point to plot.tune
but it ends up in a wrong place.
I'm calling
plot(radial.tune2, color.palette = topo.colors)
points(radial.tune2$best.parameters, pch=20, col='red')
where radial.tune2
is tune
object.
The parameters are as follows:
> radial.tune2$best.parameters
cost gamma
52 0.385 0.04125
I think this is due to the fact, that the scale bar is not taken into account (as I re-scaled the plot, the red dot appeared in different places relative to axes).
I looked into documentation, but found nothing about adding points to plots of tune
object.
I found this question which seems to have similar origin, but does not address the problem properly.
Edit: here is simplified example of the same problem. It produces different plot, but with the same shifting-to-the-right property.
library(mlbench)
library(e1071)
data(BreastCancer)
BreastCancer$Id <- NULL
BreastCancer <- na.omit(BreastCancer)
data <- as.data.frame(lapply(BreastCancer, as.numeric))
data$Class <- BreastCancer$Class
names(data) <- names(BreastCancer)
C.range <- seq(0.1, 0.7, by=0.05)
gamma.range <- seq(0.001, 0.30, by=0.05)
set.seed(1)
radial.tune <- tune(svm, train.x=data[,-10], # 10 -> Class
train.y=data[,"Class"],
kernel="radial",
ranges=list(cost=C.range, gamma=gamma.range),
tunecontrol=tune.control(sampling="bootstrap"))
plot(radial.tune, color.palette = topo.colors)
points(radial.tune$best.parameters, pch=20, col='red')