Skip to content

Logistic Regression

Ishani Kathuria edited this page Dec 24, 2022 · 2 revisions

Overview

A Logistic Regression model is similar to a Linear Regression model, except that the Logistic Regression utilizes a more sophisticated cost function, which is known as the “Sigmoid function” or “logistic function” instead of a linear function.

Types of Logistic Regression

  1. Binary Logistic Regression: The categorical response has only two 2 possible outcomes. Example: Spam or Not.
  2. Multinomial Logistic Regression: Three or more categories without ordering. Example: Predicting which food is preferred more (Veg, Non-Veg, Vegan)
  3. Ordinal Logistic Regression: Three or more categories with ordering. Example: Movie rating from 1 to 5.

Formula (Sigmoid Function)

$$\frac{1}{1+e^{-(w_0 + w_1X_1 + w_2X_2 + ... + w_nX_n)}}$$

Where $y$ is the dependent variable and $X_1, X_2, ..., X_n$ are the independent variables.

Step by Step Implementation

The Titanic dataset from Kaggle was used with columns,

  • survival
  • pclass
  • sex
  • Age
  • sibsp
  • parch
  • ticket
  • fare
  • cabin
  • embarked

The dataset can be used to predict whether a passenger will survive the titanic or not.

See implementation in Jupyter Notebook