Logistic Regression- Python

0
121

Logistic Regression is a classification algorithm. It is used to predict a binary outcome (1 / 0, Yes / No, True / False) given a set of independent variables.  This article will help you to learn how to implement Logistic Regression in Python. At the end of this article, we would have a fair idea about the basic libraries and commands required to for Logistic Regression.

Step 1: Import the Libraries. We would use three libraries for this analysis:

  • numpy
  • pyplot
  • pandas

Use below command to import the libraries.

PY_LR1

Step 2: Import the data set.

PY_LR2

Step 3: Splitting the data set into the Training set and Test set. Provided data set has 300 observations, we would divide it into 75%-25% for training and testing purpose.

PY_LR3

Step 4: Feature Scaling

PY_LR4

Step 5: Fitting Logistic Regression to the Training set

PY_LR5

Step 6: Predicting the Test set results

PY_LR6

Step 7: Making the Confusion Matrix and verifying the results

PY_LR7

Step 8: Visualizing the Training set results

PY_LR8

PY_LR91

Step 9: Visualizing the Test set results

PY_LR9

PY_LR92

LEAVE A REPLY

Please enter your comment!
Please enter your name here