Logistic Regression is supervised learning classification algorithm. In this algorithm the target attribute or dependent variable is dichotomous, which means there would be only two possible classes. In simple words, the dependent variable is binary in nature having data coded as either 1 (stands for yes/positive/success) or 0 (stands for no/negative/fail). It is used to estimate the probability that an instance which is belong to particular class.

We use the logistic function given as,

The logistic function has following characteristics:

It has value between 0 and 1.

It converges to 1 and approaches to +∞.

It converges to 0 and approaches to -∞.

It is smooth and symmetric curve.

Logistic Regression in Python with scikit learn:

In the given example we have determine that how many peoples are survived in the titanic and how many peoples are not. For that we have to import the required libraries.

import pandas as pd

import numpy as np

import seaborn as sns

import matplotlib.pyplot as plt

from sklearn.model_selection import train_test_split

from sklearn.linear_model import LogisticRegression

from sklearn.metrics import classification_report,confusion_matrix,accuracy_score

The following command is used to read the CSV file using pandas.

Download the dataset: click here