cjlin1 / libsvm

LIBSVM -- A Library for Support Vector Machines
https://www.csie.ntu.edu.tw/~cjlin/libsvm/
BSD 3-Clause "New" or "Revised" License
4.54k stars 1.64k forks source link

svm.svm_model.get_sv_indices() should return indices starting at zero for python #127

Closed helasraizam closed 5 years ago

helasraizam commented 5 years ago

I just realized that svm.svm_model.get_sv_indices() returns an index of 1 for the first elements, 2 for the second element, etc. This makes sense for matlab, but not for python, where list indices start at 0. I noticed the issue trying to reproduce matlab code, comparing the training data for indices of model.get_sv_indices() to the corresponding output of model.get_sv_indices().

cjlin1 commented 5 years ago

This isn't related to matlab. It's a C function in the core library. The reason why we decide to return [1... num_data] is related to the setting of precomputed kernels.