Regarding bias term in Logistic Regression

are we referring bias term as xo whose value is always 1 so why i have to calculate its gradient

i mean the implementation of linear regression and logistic regression algorithm will be exactly same except for the fact that our hypothesis function gets changed and error function also gets changed in case of logistic regression

so why i have to calculate gradient seperately for bias term i mean we can simply add a column of ones in our X dataset and find our optimal parameters theta

Hey @amankharb, we have to calculate the gradient for bias term separately in both linear and logistic regresion. The column of 1’s that you will add in the dataset are multiplied by the bias term only. But for bias to be optimal , we need to calculate it’s gradient separately and adjust to it’s best value.

Hope this helps :slight_smile:

but after applying vectorization method the model will itself learn the optimal solution for bias term(theta[0]). i mean after every training example the model will decrease the error and finally we will get our theta which will be of (n,1) dimension if n features were there

and gradient for bias term also will be automatically calculated when we were applying vectorization method

Yes but how will the model know whether to increase or decrease the bias ?

For that learning rate is multiplied with the gradient calculated and then the value of bias is changed accordingly.