what is Logistic Regression ?

 

Implementation of Logistic Regression 



Logistic regression is the appropriate regression analysis to conduct when the dependent variable is binary.

Basically logistic regression is working on this formula :




Now the question is there is already linear regression available then why we need logistic regression? 

Logistic regression vs linear regression :

Lets understand the concept of why we need logistic regression. consider below graph and fit line using leaner regression.




 so you can clearly saw that it's a very inappropriate way to fit line and our ml model accuracy look bad. 

Lets now fit the line using Logistic regression 



You can clearly see the difference which method is useful and accurate. 

Logistic regression in python :

Now lets do some coding

We will predict the person have insurance or not on the basis of his/her age.

First we import the library



Lets read the data from the csv file.



visualising data using scatter plot




Lest build the model and predict 



You can download data set by click here

Comments

Popular posts from this blog

Multivariate logistic regression in Python

Decision tree for titanic dataset in Python

K Means Cluster Algorithm