0

I noticed that the fit function for svmRadial in caret actually uses lssvm, but I thought the correct(intended) method should be ksvm instead. Am I missing something?

library(caret)
Loading required package: lattice
Loading required package: ggplot2
getModelInfo('svmRadial')[[1]]$fit
function(x, y, wts, param, lev, last, classProbs, ...) { 
                    lssvm(x = as.matrix(x), y = y,
                          kernel = rbfdot,
                          kpar = list(sigma = param$sigma), ...)         
                  }
getModelInfo('lssvmRadial')[[1]]$fit
function(x, y, wts, param, lev, last, classProbs, ...) { 
                    lssvm(x = as.matrix(x), y = y,
                          kernel = rbfdot,
                          kpar = list(sigma = param$sigma), ...)         
                  }
sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.3 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] caret_6.0-47    ggplot2_1.0.1   lattice_0.20-31

1 Answer 1

0

Using iris dataset (R 3.2.0, kernlab_0.9-20, caret_6.0-47):

library(caret)

data(iris)
TrainData <- iris[,1:4]
TrainClasses <- iris[,5]

out1 <- train(TrainData, TrainClasses, method = "svmRadial")
# Loading required package: kernlab
class(out1$finalModel)
# [1] "ksvm"
# attr(,"package")
# [1] "kernlab"

out2 <- train(TrainData, TrainClasses, method = "lssvmRadial")
class(out2$finalModel)
# [1] "lssvm"
# attr(,"package")
# [1] "kernlab"

According to the output, it seems that method "svmRadial" is using ksvm from kernlab package.

2
  • Thanks. It turns out I was looking at the wrong element in the model list. lapply(getModelInfo('svmRadial'), '[[', 'label').
    – user1642513
    May 21, 2015 at 15:10
  • Use the regex = FALSE option to to getMoelInfo to avoid this
    – topepo
    May 27, 2015 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy