Ch.04
Logistic Regression: Pass or Fail?
Where linear regression predicts a 'score', logistic regression is the specialist for yes/no classification—e.g. "Will this score mean pass (1) or fail (0)?" It uses the sigmoid function to turn a score into a probability between 0 and 1.
ML diagram by chapter
Select a chapter to see its diagram below. View the machine learning flow at a glance.
The larger the linear score , the closer is to 1, so we classify as class 1. is the decision boundary.
Sigmoid: . When , ; when , .
How to read the formula — When is large and negative, is large so . When , . When is large and positive, so . So the formula squeezes any into a probability between 0 and 1.
Logistic Regression: Pass or Fail?
The S-curve: sigmoid — The score from a linear model can be large or negative. Probabilities must lie between 0 and 1. The sigmoid maps any real into (0, 1).
Decision boundary — When the sigmoid outputs e.g. "probability of pass = 0.7", we need a rule. Usually we use 0.5: if probability ≥ 0.5 we predict 1 (yes), otherwise 0 (no).
Same core as linear regression — Logistic regression still computes a score first; the only difference is passing that score through the sigmoid to get a probability.
How to read — When is large and negative, is large so . When , . When is large and positive, so . So any is squeezed into a probability in [0, 1].
Many real problems are yes/no — Spam or not? Disease or not? Will the user buy? Binary classification is everywhere; logistic regression is the standard baseline.
Confidence as a number — Saying "pass with 98% probability" is more useful than just "pass". Logistic regression gives a probability, which supports better decisions.
Bridge to deep learning — A single neuron in a neural network behaves much like logistic regression. Mastering this makes deep learning easier later.
Spam filter — Compute "probability this email is spam" from features; if above a threshold, send to spam.
Medical AI — From X-rays or lab values, predict "probability of disease" to support diagnosis.
Marketing and recommendations — Predict "will this user churn?" or "will they click?" for targeting and ads.
Logistic regression summary — It is for binary classification (yes/no, pass/fail). We compute a linear score , then apply the sigmoid to get a probability. We predict if probability ≥ 0.5, else ( is the decision boundary). It is important because many real tasks are binary; it also gives confidence (probability) and is the basis for understanding neurons in deep learning. Used in spam filters, medical decision support, and marketing (churn, click prediction). Solution flow: compute → → if then , else . See the Explanation for problem solving block below for examples.