Bit Manipulator
Bit Manipulator

Reputation: 358

Why less number of features being ranked in SVM as compared to actual provided?

I have trained a SVM with 18881 features and wanted to know the ranking of features. I tried the method given at 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

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?

Upvotes: 1

Views: 136

Answers (1)

Bit Manipulator
Bit Manipulator

Reputation: 358

Ok, I got the explanation because of help provided in comments by @BondedDust. 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

Upvotes: 1

Related Questions