Blog

code illustration

Category: Expert stories

Machine Learning Algorithm: Logistic Regression

Logistic Regression is a Linear Model for classification; a traditional linear model that is used to predict a numerical value, like how it is used by many e-mail providers to determine whether an e-mail is Spam or Ham.

Understand how logistic Regression works and how it differs from Linear Regression.

By Alan Lehane, Developer

In this blog, you will learn about Logistic Regression, another type of Linear Algorithm. I recommend reading my previous blog on Linear Regression to understand this blog fully.

Read: Linear Regression

What is logistic Regression?

Logistic Regression is a Linear Model for classification; a traditional linear model is used to predict a numerical value, whereas a logistic model is used to predict into which category an example belongs.

An example of a Logistic Regression Model is a system many e-mail providers use to determine whether an e-mail is Spam or Ham.

The e-mail details are given to the model, and the model categorises the e-mail as Spam or Ham and moves the mail into the appropriate folder.

 

How does logistic Regression work?

A Logistic Regression algorithm calculates the probability of an example belonging to each category.

The algorithm structure is the same as a Linear Algorithm, which I covered in a previous blog. Each input variable is assigned a coefficient; the difference is that the Log of the Equation is determined, confining the Equation between 0 & 1.

This answer is the probability of the current example being a member of the default category.

y = Log (C_1 x+C_2 x_2+C_3 x_3)
0<y<1

In the determine spam example, y is the probability of whether an e-mail is Spam. For instance, if y=0.7, there is a 70% chance that the mail is Spam.

 

Training

A Logistic Regression model is trained the same as a Linear Regression Model; the modal iterates through a training set of known examples, adjusting the coefficients when predictions are incorrect.

 

Data Preparation

Data Preparation is very similar to Linear Regression with some key differences.

  • Non-Discrete Output Variable – All the Training Set output variables must be members of a fixed number of categories.
  • Noise Sensitivity – Logistic Regression is much more sensitive to outliers and incorrect data than linear Regression, so Data Quality standards need to be higher.
  • Gaussian Distribution – It is assumed that there is a linear relationship between the input and output variables.

Types of Logistic Regression

The Linear Regression algorithms I discussed in my previous blog, such as Ordinary Least Squares & Gradient Descent, can also be applied to logistic problems. However, a more suitable method is Maximum-likelihood Estimation. This algorithm favours and prioritises predictions that are closer to the extremes of the prediction range. EG.

In our e-mail example, as close to 1 or 0 as possible, resulting in more definitive predictions; predictions close to 0.5 are discouraged.

Alan Lehane, Software Developer

Alan has worked with Aspira/emagine for several years as a Software Developer, specialising in Data Analytics and Machine Learning. He has provided various services to Aspira's clients, including Software Development, Test Automation, Data Analysis and Machine Learning.

Blog

More insights

left-arrow
right-arrow

Two young professionals sitting in a meeting.
Expertise strategy
Tech & Development

IT leaders are reclaiming control – here’s why

The IT landscape is shifting fast. As old outsourcing models show their cracks, forward-thinking leaders are rebuilding internal strength and redefining what smart partnerships look like. A trend is emerging where decoupling and taking back ownership takes the stage.

The agile transformation of a large enterprise is a complex process that requires profound changes in leadership, structure, and corporate culture.
Expertise strategy
Projects & Implementation
Tech & Development

Developments of AI in Project Management

This article discusses how the integration of artificial intelligence (AI) and machine learning (ML) into project management is driving a cultural shift towards innovation and agility within organizations.

Tech & Development
Trends

From Sci-fi to Reality: The future of the automotive industry

Discover the future of the automotive industry with insights into the rise of autonomous driving, electric vehicles, and AI innovations. Learn about new regulations, industry challenges, and groundbreaking technologies transforming transportation and car manufacturing.