← the late compiler
C_000228 · machine learning · advanced

Logistic Regression

Modelling the log-odds of a binary outcome as a linear function of predictors, giving calibrated probabilities.

Step 1 of 4

In words

What it is, why it matters, and what it is like.

Why am I learning this?

Logistic regression is the foundation for understanding how AI makes decisions with probabilities. It is the first model you will meet that outputs a confidence, not just a yes/no. Mastering it unlocks the study of neural networks (which are stacked logistic regressions), classifiers like decision trees and Naive Bayes, and the evaluation metrics you will use everywhere. If you plan to build any system that predicts a category—fraud detection, disease diagnosis, churn prediction—this is the starting line.

The idea, in plain terms

You want to predict a yes/no outcome, like 'will this customer leave?' or 'is this email spam?'. You have some numbers about the case, like age or income. Logistic regression combines those numbers into a single score, then converts that score into a probability between 0 and 1. The math is simple: each input number is multiplied by a weight that says how important it is, all those products are added together, and the total is 'squashed' into a probability by a special curve. The trick is that the curve (called the sigmoid) always produces a value between 0 and 1, so the output can be read as a chance. The model learns the weights from data, so it finds the combination that makes the probabilities match the actual outcomes as closely as possible.

An analogy

Think of a doctor assessing a patient's risk of a heart attack. The doctor looks at several measurements: blood pressure, cholesterol, age. Each one gets a certain level of concern based on experience—high blood pressure is a big red flag, age is a moderate one. The doctor mentally adds up these weighted concerns, but doesn't blurt out a raw score; they translate it into a probability: 'your risk is about 70%'. That translation is the logistic function. The doctor also has a baseline tendency to be cautious or lax, which is like the bias term. Now, how does the doctor learn the weights? Not from a textbook, but from seeing thousands of past patients and their outcomes. That is exactly how logistic regression learns—from examples, adjusting the weights until its probabilities match reality. This analogy breaks down in a key way: the doctor also uses intuition, experience, and subtle patterns that no simple weighted sum can capture. Logistic regression only sees a linear combination of the inputs—it cannot capture interactions where, say, high blood pressure is dangerous only if the patient also has diabetes. So it is a smart but limited assistant, not a replacement for complex reasoning.

Definition

Logistic regression models the log-odds (the natural logarithm of the odds) of a binary outcome as a linear combination of the input features, and then converts those odds into a probability using the logistic function.

Where this sits

You have not yet studied any other models, but note that logistic regression is closely related to Linear Regression, which you will learn soon: both are linear models, but linear regression predicts a continuous number, while logistic regression predicts a probability. It is also the simplest example of a 'classifier' and the standard baseline that every other classifier (like decision trees or Naive Bayes) must beat. It builds directly on the idea of fitting a line to data, which you will meet in Linear Regression.

Signal from the Frontier

Get the next essay on mind, machine, and meaning

Essays at the intersection of AI, philosophy, and Indian governance. No promotional content.

We'll send a one-click sign-in link to confirm. No password needed.

Views expressed are personal and do not represent the Government of India or the Government of Uttarakhand.