scikit-learn/scikit-learn — pull request #546 by amueller (2012-01-09 22:31:16+00:00)
Title: MRG Svm coef sign in liblinear

This is the first part of addressing issue #91.
I'd like to see if this is ok for everybody before doing the same for liblinear.

The issue was that the signs of the decision function are flipped for the two class case in liblinear and libsvm.
To put it otherwise, some wrapping code sorts classes in ascending order while the libsvm code expects the first class in a two class setting to be '+1' and the second one '-1'.

I "fixed" this by swapping the roles of +1 and -1 in liblinear.
I felt this is the cleanest solution. I am a bit weary of touching the liblinear code since that could complicate upgrades.

What do you think?

The main reason that I did not do this in cython is the following:
The Cython wrappers get their coefs for prediction from the Python class.
If I want to switch the sign there, I'll have to switch it back when doing predictions.
So I have to switch it after fit, before calling predict or decision function and then switch again on the value of the decision function.
This seemed ugly and confusing to me.

If people think that it is a very bad idea to change anything in liblinear, then I'll do the cython level fix.