liblinear-java
liblinear-java copied to clipboard
Is a bias term added to the features automatically?
I am maintaining code that I mostly didn't write which uses liblinear for logistic regression. My understanding from the documentation was that setting bias to a value greater than 0 will result in a synthetic feature being added. But I cannot see anywhere in the code where this feature is added either during training or prediction. Is it required to both set the bias parameter to a value greater than 1 and also manually add the synthetic feature node during training and prediction?
Yes, the bias feature is added automatically, if bias
is ≥ 0. You can find all the places in the code, when you search for bias >= 0
.
Please note that I just translated this logic from the original C++ sources. I would have probably designed it in a slightly different way ;)
Hey thanks for your reply! Yeah I realize the code is autogenerated, so I didn't know if I should ask here or in the c++ project. Looking over the code, I see that a feature node is initialized with a value of new FeatureNode(n, model.bias)
in the Train and Predict scripts, but that doesn't appear happen in the static functions provided by the Linear class from what I can tell. I'm not sure if it happens in the C++ code. It looks essentially the same to me, but I am not 100%.
I noticed that my generated models end up with a bias weight of 0, so thats what has me wondering about this. For clarification I am not using the commandline scripts, I am using the linear static functions directly.