rapidminer / rapidminer-studio

Outdated version of RapidMiner Studio 7.x - 9.7. See rapidminer-studio-modular for the latest version 9.8+
https://www.rapidminer.com
GNU Affero General Public License v3.0
427 stars 225 forks source link

LibSVMModel returns wrong number of support vector and computes wrong weights #4

Open Whadup opened 8 years ago

Whadup commented 8 years ago

Hi there,

in the class LibSVMModel, the methods for returning the number of support vectors and computing the weight vector are wrong. getNumberOfSupportVectors should use the correct field computed by libSVM, as the current implementation will return the number of classes-1 not the number of support vectors.

    public int getNumberOfSupportVectors() {

        //return model.SV.length;

                return model.l;

    }

Furthermore, the weight vector w as computed by the implementation of createWeightsTable() in KernelModel is wrong. For LibSVM, the weight w[i] = m.getAlpha(i) * x[j]. Do not multiply with y here. Also I'm not sure if the implementation in KernelModel is correct, as y is either 0 or 1, however in SVM Literature it is -1 or 1. I suspect that replacing y with (y == 0 ? -1 : 1) is correct.

Best wishes

Lukas

ncwoehler commented 8 years ago

Hi Lukas,

thanks for reporting the bug! I've created a bug report in our internal tracker. We'll close this issue once the bug has been fixed.

Thanks, Nils