简体   繁体   中英

R ksvm support vectors

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM