LOGISTIC REGRESSION WITH PYTHON

Posted by ruchika on December 25th, 2018

Why learn Python?

Developers love Python due to how quick and simple it is to utilize. Python slices development time down the middle with its easy to peruse grammar and simple aggregation include. Investigating your projects is a breeze in Python with its inherent debugger. Utilizing Python makes Programmers progressively gainful and their projects eventually better. Python keeps on being a most loved choice for information researchers who use it for building and utilizing Machine learning applications and other logical calculations. Python keeps running on Windows, Linux/Unix, Mac OS and has been ported to Java and .NET virtual machines. Python is allowed to utilize, notwithstanding for the business items, in view of its OSI-endorsed open source permit. Python has advanced as the most favored Language for Data Analytics and the expanding seek slants on python additionally shows that Python is the following "Enormous Thing" and an unquestionable requirement for Professionals in the Data Analytics area.

What Is Regression?

Regression analysis is a predictive modeling technique.

Is estimates the relationship between a dependent(target) and an independent variable(predictor).

What Is Logistic Regression?

Logistic Regression produces results in a binary format which is used to predict the outcome of a categorical dependent variable. So, the outcome should be discrete or categorical.

LOGISTIC REGRESSION EQUATION

The Logistic Regression Equation is derived from the Straight Line Equation.

Equation of a straight line

Y = C + B1X1 + B2X2 + …. -------- Range is from –(infinity) to (infinity)

Let’s try to reduce the Logistic Regression Equation from Straight Line Equation

Y = C + B1X1 + B2X2 + …. -------- In Logistic equation Y can be only from 0 to 1

Now, to get the range of Y between 0 and infinity, let’s transform Y

Y      Y=0 then 0

1-Y   Y=1 then infinity          --------- Now the range is between 0 to infinity

Let us transform it further to get range between –(infinity) and (infinity)

Log(y/1-y) --- Y = C + B1X1 + B2X2 + …. -------- Final Logistic Regression Equation

LINEAR VS LOGISTIC REGRESSION

LINEAR REGRESSION

LOGISTIC REGRESSION

  • Continuous variables

  • Solves regression problems


  • Straight line

  • Categorical variables

  • Solves classification problems

  • S-curve

LOGISTIC REGRESSION – USE-CASES

  • Weather predictions

  • Classification problems

  • Determines illness

IMPLEMENT LOGISTIC REGRESSION

  • Collecting data : import libraries

  • Analyzing data : creating different plot to check relationship between variables

  • Data wrangling : clean the data by removing the Nan values and unnecessary columns in the dataset

  • Train & Test : build the model on the train data and predict the output on the test data

  • Accuracy check : calculate accuracy to check how accurate your results are.

 

Like it? Share it!


ruchika

About the Author

ruchika
Joined: November 14th, 2018
Articles Posted: 26

More by this author