[R] tuning values of SVM

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Wed Dec 11 11:22:38 CET 2019


You have:

lower = c(0.2, 4), upper = c(0.1, 0.9)

Isn't this backwards? -- you need to switch lower and upper


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Dec 11, 2019 at 1:53 AM javed khan <javedbtk111 using gmail.com> wrote:

> I want to optimize the cost and sigma parameters of SVM using Caret and
> PSO. The following code I am using after imported the data.
>
> svm_obj <- function(param, maximize = FALSE) {
>   mod <- train(log10(Effort) ~ ., data = tr,
>                method = "svmRadial",
>                preProc = c("center", "scale", "zv"),
>                metric = "MAE",
>                trControl = ctrl,
>                tuneGrid = data.frame(C = 10^(param[1]), sigma =
> 10^(param[2])))
>   if(maximize)
>     -getTrainPerf(mod)[, "TrainRMSE"] else
>       getTrainPerf(mod)[, "TrainRMSE"]
> }
>   num_mods <- 10
>
> And for the PSO, the following code
>
> library(pso)
>   set.seed(45642)
>   pso_res <- psoptim(par = c(0, 0), fn = svm_obj,
>                      lower = c(0.2, 4), upper = c(0.1, 0.9),
>                      control = list(maxit = ceiling(num_mods)))
>   pso_res
>
> Now, it gives me the result but when I try to get the optimal values of C
> and sigma using pso_res$par, it gives me the values:
>
> 0.1 and 0.9
>
> The minimum value I provided for C is 0.2 (and maximum value is 4 as shown
> above), but how can it give me the optimal value 0.1, which is even lower
> than the minimum provided value.
>
> Where I am doing mistake?
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list