What is logistic regression?
Logistic regression is used in classification problems. Let’s say we are given the sepal length, sepal width, petal length, and petal width of two types of flowers. Based on these parameters, we have to classify the type of flower.
Here, there are four features and two classifications. We can use logistic regression in this case.
We have seen in linear regression if Y is the target variable and X is the predictor variable, then the relationship between X and Y can be written as:
In the case of logistic regression, the output of the linear regression is passed through the logistic function or sigmoid function. The logistic function can be expressed as:
If we draw the curve of the equation, we get an S-shaped curve. The curve is also known as the sigmoid curve.
Equivalently, we can also write:
This function is known as the logit function.
Logistic Regression using the sklearn Python library
Let’s say we are given the sepal length, sepal width, petal length and petal width of two types of flowers. Based on these parameters, we have to classify the type of flower. We can use the following Python code for this logistic regression model…
0 Comments