lynaghk / clj-liblinear

A Clojure wrapper for LIBLINEAR, a linear support vector machine library
http://keminglabs.com/clj-liblinear/
Eclipse Public License 1.0
28 stars 9 forks source link

support for bias different from 1 #8

Closed daslu closed 10 years ago

daslu commented 10 years ago

The liblinear bias parameter is defined as follows (README.md at commit 7b6c6a56c1 of liblinear java): https://github.com/bwaldvogel/liblinear-java/blob/master/README.md "if bias >= 0, instance x becomes [x; bias]; if < 0, no bias term added (default -1)".

clj-liblinear does support the use of bias (thanks to #4 by @akhudek).

Currently in clj-liblinear, the only supported bias values are 0 and 1: https://github.com/lynaghk/clj-liblinear/blob/master/src/clj_liblinear/core.clj#L54 Also, the bias=0 case results in not adding the extra featue: https://github.com/lynaghk/clj-liblinear/blob/master/src/clj_liblinear/core.clj#L64

I suggest to the following changes: (1) Support all bias values. (2) Let the bias=0 case behave like documented in liblinear-java: adding an extra feature of value 0.

Reasons for the change:

If desired, I can suggest a pull request with these changes. What do you think?

lynaghk commented 10 years ago

Agreed, this seems like a very reasonable addition. A pull request would be awesome. My only request is that you handle the case of true/false inputs by converting to 1 or 0, respectively to maintain backwards compatibility for existing callers.

daslu commented 10 years ago

Hi,

I have seen the deprecation notice, so I guess the pull request is not relevant here anymore. I am fixing this at my fork.

Let us keep in touch in case you are interested in it again, one day.

Again, many thanks for this very nice project.

lynaghk commented 10 years ago

Will do, I'll contact you about a redesign if that is ever in the cards.

akhudek commented 10 years ago

Hey daslu, (2) would be the same thing as simply leaving the bias feature out since w*0=0.

daslu commented 10 years ago

Thanks, yes, this seems to be true for all the various objective functions supported by liblinear-java. I have no idea why liblinear-java supports adding a zero column.