0

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

Point appearing to the right of where it should be

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')
Esgeriath
  • 111
  • 5

1 Answers1

0

I found out that this is actually problem of filled.countour which is being called under the hood. See this thread for more info.

Esgeriath
  • 111
  • 5
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 29 '23 at 21:48