# creating a logistic regression model with coefficients

I am trying to understand the details of the logistic regression models and now I was wondering how the model can be created if you have the coefficients and intercepts.

So I created a logistic regression model in python and I extracted the coefficients and intercepts. Now I want to calculate those by hand, just to see how it works. Does it make sense to calculate it like a linear regression (y = a + bx1 + bx2 ) and then if the given value is less than your threshold, predict the output as 0, otherwise as 1?

I have already done it but my concern is that some of the predicted probabilities (output) came out negative and a few were more than 1.

Thank you

You first perform the calculation as you would for a linear regression, but before using the treshold to predict either 0 or 1 you first have to pass the result (i.e. the y value from your formula) through the sigmoid function to make sure all values are between 0 and 1. In reality, the formula for logistic regression (before thresholding) would therefore be as follows:
$$$$y = \frac{1}{1+e^{-(\alpha + \beta_1 x_1 + \beta_2 x_2)}}$$$$