Sitemap
TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Simple Logistic Regression in Python

Step-by-Step Guide from Data Preprocessing to Model Evaluation

10 min readMar 30, 2021

--

Press enter or click to view image in full size
logistic regression python cheatsheet (image by author from www.visual-design.net)

What is Logistic Regression?

Don’t let the name logistic regression tricks you, it usually falls under the category of the classification algorithm instead of regression algorithm.

Then, what is a classification model? Simply put, the prediction generated by a classification model would be a categorical value, e.g. cat or dog, yes or no, true or false … On the contrary, a regression model would predict a continuous numeric value.

Logistic regression makes predictions based on the Sigmoid function which is a squiggles-like line as shown below. Despite the fact that it returns the probabilities, the final output would be a label assigned by comparing the probability with a threshold, which makes it eventually a classification algorithm.

Press enter or click to view image in full size
simple illustration of sigmoid function (image by author)

In this article, I will walk through the following steps to build a simple logistic regression model using python scikit -learn:

  1. Data Preprocessing
  2. Feature Engineering and EDA

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Destin Gong
Destin Gong

Written by Destin Gong

On my way to become a data storyteller Substack (weekly posts): https://substack.com/@datavisualdesign YouTube Channel: Visual Design Studio