Logistic Regression Techniques


In case of Logistic Regression Regression is it mandatory to have
a) the independent & target variable as categorical(Yes/No, 1/0)
b) independent variable as continuous & target to be categorical(Yes/No, 1/0)

What is the right procedure mentioned above? And what about the linear regression independent variable?

1 Like

Hi @swarup17,

Logistic regression is used to solve classification tasks. Hence the target variable should be categorical. The independent variables can either be categorical or continuous or a combination of both.

Same goes with Linear regression, the target should be continuous as linear regression is used for regression tasks and independent variables can be either categorical or continuous or both.

1 Like

Thanks Pulkit for the reply…
IF it is so then,
for categorical variable present in the independent data it can be in string form such as Yes/No or can be categorical numerical form as 1/0 how we gonna relate it to the target variable which is categorical string form & categorical numerical?


Hi @swarup17,

If you are using sklearn to build your models, it takes only numeric inputs. So, even if the categories are Yes/No, you have to convert them to numbers.

1 Like

Actually I am using import statsmodel.api as it contain the logit() which internally extracts the probability


Hi @swarup17,

If you have categorical variables in your independent if you convert them to numbers using one hot encoding technique, it may not work because the converted values becomes of ordinal form and your model will not perform well. In such cases you need to use categorical encoding using scikit learn package.

Also linear regression does not work for classification problems, since it fits a linear curve. Yes you can fit the curve by using higher degree polynomials (non - linear ) of which we may be inducing overfit. Logistic regression models are great with classification problems since the it uses the best ‘S’ curve.


Hi Sunil,

Independent Categorical can be of two types
(a) Gender(M/F) covert them to 1 & 0 respectively?
(b)Gender(1/0) no need to make changes