Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Whadup opened this issue Apr 8, 2016 · 1 comment

Comments

@Whadup
Copy link

Whadup commented Apr 8, 2016

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants