2

I am trying to extract weights for R's ksvm package.

Usually I use the e1071 package and the weights can be computed by

 weights = t(svmmodel$coefs) %*% svmmodel$SV

However, when I look into the ksvm package, both the coefficients and alphas (support vectors) are lists of the same dimension. The alphas do not return vectors.

My question is, how should I access the support vectors including the zero values? Would I have to use SVindex to correspond the variables back to the original input?

Thanks.

agstudy
  • 119,832
  • 17
  • 199
  • 261
Florie
  • 251
  • 3
  • 9

1 Answers1

0

Use xmatrix in the ksvm model (https://www.rdocumentation.org/packages/kernlab/versions/0.9-29/topics/ksvm-class). The xmatrix slot of the ksvm model svmmodel can be accessed using svmmodel@xmatrix.