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

Is a bias term added to the features automatically? #42

Open
bmccord2 opened this issue Feb 8, 2022 · 2 comments
Open

Is a bias term added to the features automatically? #42

bmccord2 opened this issue Feb 8, 2022 · 2 comments

Comments

@bmccord2
Copy link

bmccord2 commented Feb 8, 2022

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?

@bwaldvogel
Copy link
Owner

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 ;)

@bmccord2
Copy link
Author

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.

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