Logistic regression

Supervised · Classification Despite its name, logistic regression is used to answer yes/no questions. It combines the features into a score, then squashes that score through an S-shaped curve (the sigmoid) into a probability between 0% and 100%. If the probability is above a threshold, usually 50%, the answer is "yes".

Everyday analogy

A weather app that says "70% chance of rain". You decide: above 50%, take an umbrella. Logistic regression gives the percentage; the threshold makes the decision.

Example

Used for: predicting customer churn, loan default risk, disease risk screening, whether a user will click an ad.

50% cut-offPass ✓Fail ✗Hours studied →
Logistic regression turns a score into a probability with an S-curve, then applies a cut-off.

The S-curve turns a score into a probability

0%50%100%thresholdMonths without using the app →below line: "will stay"above line: "will leave"

How it works, step by step

  1. Collect examples with a known yes/no outcome, such as customers who stayed or left.
  2. Give each feature a weight and add them up into a single score.
  3. Pass the score through the S-curve to get a probability between 0 and 1.
  4. Compare the probability with the threshold (often 0.5) to decide yes or no.
  5. During training, adjust the weights so the predicted probabilities match the real outcomes as closely as possible.

Worked example

A streaming app looks at how long customers haven't used the app. 0 months inactive → 5% chance of leaving. 3 months → 40%. 6 months → 85%.

With a 50% threshold, the 6-month customer is flagged, and the app sends them a special offer before they cancel.

✓ Good for

  • Gives a probability, not just yes/no
  • Fast, and easy to explain which factors raise the risk
  • Works well when the groups are fairly easy to separate

⚠ Watch out for

  • Draws only a simple, straight boundary between the groups
  • The threshold matters: a false alarm and a missed case can have very different costs
  • Needs features prepared carefully

Try it yourself

About 10 min

Turn a score into a yes/no

  1. Make a list of 10 students with hours studied and pass or fail.
  2. Find the hours where most students switch from fail to pass.
  3. Ask an AI chatbot to explain how logistic regression would draw that S-curve.

What you should see: Logistic regression gives the probability of a yes, with a cut-off point.

Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.

Build it for real · guided projectFind customer groups with K-means clusteringAbout 45 min · Copy-paste code · step by step
Test what you learned

Take a quick quiz, or look up any word in the glossary.