@@ -1907,11 +1907,13 @@ func (this *SVM) SVM_train(prob *SVM_Problem, param *SVM_Parameter) *SVM_Model {
19071907model .l = nSV
19081908model .SV = make ([][]SVM_Node , nSV )
19091909model .sv_coef [0 ] = make ([]float64 , nSV )
1910+ model .sv_indices = make ([]int , nSV )
19101911j := 0
19111912for i = 0 ; i < prob .l ; i ++ {
19121913if math .Abs (f .alpha [i ]) > 0 {
19131914model .SV [j ] = prob .x [i ]
19141915model .sv_coef [0 ][j ] = f .alpha [i ]
1916+ model .sv_indices [j ] = i + 1
19151917j ++
19161918}
19171919}
@@ -2065,10 +2067,12 @@ func (this *SVM) SVM_train(prob *SVM_Problem, param *SVM_Parameter) *SVM_Model {
20652067
20662068model .l = nnz
20672069model .SV = make ([][]SVM_Node , nnz )
2070+ model .sv_indices = make ([]int , nnz )
20682071p = 0
20692072for i = 0 ; i < l ; i ++ {
20702073if nonzero [i ] {
20712074model .SV [p ] = x [i ]
2075+ model .sv_indices [p ] = perm [i ] + 1
20722076p ++
20732077}
20742078}
@@ -2244,6 +2248,18 @@ func (this *SVM) SVM_get_labels(model *SVM_Model, label []int) {
22442248}
22452249}
22462250
2251+ func (this * SVM ) SVM_get_sv_indices (model SVM_Model , indices []int ) {
2252+ if model .sv_indices != nil {
2253+ for i := 0 ; i < model .l ; i ++ {
2254+ indices [i ] = model .sv_indices [i ]
2255+ }
2256+ }
2257+ }
2258+
2259+ func (this * SVM ) SVM_get_nr_sv (model SVM_Model ) int {
2260+ return model .l
2261+ }
2262+
22472263func (this * SVM ) SVM_get_svr_probability (model * SVM_Model ) float64 {
22482264var rst float64
22492265if (model .param .svm_type == EPSILON_SVR || model .param .svm_type == NU_SVR ) && model .probA != nil {
0 commit comments