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.

Step 2: Import the data set.

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.

Step 4: Feature Scaling

Step 5: Fitting Logistic Regression to the Training set

Step 6: Predicting the Test set results

Step 7: Making the Confusion Matrix and verifying the results

Step 8: Visualizing the Training set results

Step 9: Visualizing the Test set results