为什么与实际提供的功能相比,在SVM中排名的功能数量更少?

时间:2014-12-31 20:10:28

标签: r svm ranking feature-selection

我已经培训了一个具有18881功能的SVM,并想知道功能的排名。我尝试了SVM equations from e1071 R package?给出的方法,并通过

找到了权重向量
w = t(model$coefs) %*% model$SV

w之后检查str(w),我得到以下信息:

> 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

我猜测@ja正在给出功能的列ID,而@ra正在给出相应的权重。在这种情况下,为什么要素的数量不等于18881。

当我说@ja是功能的列ID时,我是否正确?

正如在上面提到的stackoverflow答案中所解释的那样,我使用了线性核心。我可以为径向内核应用相同的方法吗?

1 个答案:

答案 0 :(得分:1)

好的,我得到了解释,因为@BondedDust在评论中提供了帮助。 sparseM不存储0值单元格,因此此处不存储具有0权重的要素。

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