1
$\begingroup$

I have trained a SVM with 18881 features and wanted to know the ranking of features. I tried the method given at https://stackoverflow.com/questions/7390173/svm-equations-from-e1071-r-package for it and found the weight vector by

w = t(model$coefs) %*% model$SV

On checking w by str(w), I get the following:

> str(w)
Formal class 'matrix.csr' [package "SparseM"] with 4 slots
  ..@ ra       : num [1:16725] 1198.1 229 107.5 -22.4 408.3 ...
  ..@ ja       : int [1:16725] 381 396 434 447 3262 4802 9187 10398 11856 13896 ...
  ..@ ia       : int [1:2] 1 16726
  ..@ dimension: int [1:2] 1 18881

Please explain me the meaning of these @ra etc. I guessed that @ja is giving the column id of feature and @ra is giving the corresponding weight. In that case why number of features is not equal to 18881.

Am I correct when I say that @ja is column id of features?

As was explained in the mentioned stackoverflow answer, I used linear kernal. Can I apply the same method for Radial Kernel?

$\endgroup$

1 Answer 1

0
$\begingroup$

Ok, I got the explanation because of help provided in comments at link. The sparseM doesn't store the 0 value cells and hence the features having 0 weights are not stored here.

ra: Object of class numeric, a real array of nnz elements containing the **non-zero elements** of A.
ja: Object of class integer, an integer array of nnz elements **containing the column indices of the elements stored in ‘ra’**.
ia: Object of class integer, an integer array of nnz elements containing the row indices of the elements stored in ‘ra’.
dimension: Object of class integer, dimension of the matrix
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.