Ticker

6/recent/ticker-posts

Logistic Regression and its implementation in python:

 

What is the difference between Regression and classification?

Classification and regression are the two types of supervised algorithms. 


Classification: Based on different parameters Classification algorithm classifies or identifies the object to which category they belong to.


Regression: Based on the correlation between independent and dependent variables, it predicts the continuous output.


Regression in Machine learning

Classification in Machine Learning


Logistic Regression:

If there are two classes, it classifies the target variable into either of two classes. Mostly it is classified into binary 1 or binary 0. It is used in spam detection, cancer detection, probability of getting insurance etc.

Types of Logistic Regression:

Based on the number of classes it classifies, it is divided into 
Binary 
Multinomial 
Ordinal

Binary:

Here there are only two classes and the logistic regression classifies into binary 1 or binary 0. For example, yes or no, fail or pass, true or false etc

Multinomial:

If there are more than two classes like ‘Group A’, ’Group B’ and ‘Group C’ to be classified and the order doesn’t matter, then it comes under multinomial classification. 

Ordinal:

If there are more than two classes to be classified and the order matters, then it comes under ordinal classification. For example, poor, good, excellent etc.

Binary Logistic Regression:

Binary Logistic Regression

The sigmoid curve is given by
Z=1/(1+e-Z)

e= Euler’s number=2.71828

The sigmoid function Z converts the input into range 0 and 1. So, when the output is greater than 0.5 it is ‘yes’ and when it is less than 0.5 it is ‘no’.

Implementation of Logistic regression in Python:

Importing libraries:


Loading dataset and viewing first five rows:


Overall information about the dataset:


Number of rows and columns:


 Describing the dataset:


Number of null values:


Pairplot:


Setting dependent and independent variables:
Splitting the dataset into train and test:
Feature scaling:
Fitting the model:

Analyzing the performance of the model:





























Post a Comment

0 Comments