Logistic Regression

It is the supervised learning method for binary classification problems (problems with two class values).

Logistic Regression was used in the biological sciences in early twentieth century. It was then used in many social science applications. Logistic Regression is used when the dependent variable(target) is categorical.

For example,

  • To predict whether an email is spam (1) or (0)

Consider a scenario where we need to classify whether an email is spam or not. If we use linear regression for this problem, there is a need for setting up a threshold based on which classification can be done. Say if the actual class is malignant, predicted continuous value 0.4 and the threshold value is 0.5, the data point will be classified as not malignant which can lead to serious consequence in real time.

Logistic Regression pipeline:-

Data Preparation


Create Train & Test


Decision Boundary

# Data Preparation

# Data Normalization mean we want entire data to have 0 mean and unit standard deviation

# Logistic Regression Implementation

# To find the line

# Decision Surface



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store