Back to Machine Learning Notes
Topic #105

Logistic Regression vs Linear Regression

Despite sharing "regression" in the name and a nearly identical training loop, logistic and linear regression solve fundamentally different problems — this note is the direct, side-by-side comparison worth knowing cold for interviews.

Side-by-Side Comparison

Linear RegressionLogistic Regression
PredictsA continuous numberA probability (then thresholded into a class)
Output rangeAny real number, unbounded(0, 1), bounded by the sigmoid
Equation\(\hat{y} = w^Tx+b\)\(\hat{y} = \sigma(w^Tx+b)\)
Cost functionMSELog-loss
Cost surface shapeConvex (guaranteed)Convex (guaranteed, specifically because log-loss is paired with sigmoid)
Evaluation metricsRMSE, R², MAEAccuracy, Precision/Recall, ROC-AUC
Decision boundaryNot applicable (no classes)Linear in feature space
Example use casePredicting house pricePredicting whether a house sells within 30 days

What They Actually Share

  • Both compute \(z = w^Tx+b\) as the very first step — a linear combination of features
  • Both are interpretable — coefficients have a direct, explainable meaning (though logistic regression's are in log-odds terms)
  • Both are trained by minimizing a convex cost function via gradient descent or a closed-form-style solver
  • Both are common first-choice baselines before reaching for more complex algorithms

The One-Sentence Distinction

Linear regression models the target directly as a linear function of the features; logistic regression models the target's log-odds as a linear function of the features, then converts those log-odds back into a bounded probability with the sigmoid — see Logistic Regression Intuition for the full derivation of why.

Choosing Between Them — A Simple Test

# Look at the target variable itself
if target_is_continuous_number:      # price, temperature, sales volume
    use_linear_regression()
elif target_is_binary_category:       # yes/no, fraud/not-fraud, churn/no-churn
    use_logistic_regression()

The choice is almost always determined entirely by what kind of variable you're trying to predict — not by dataset size, feature types, or any other consideration.

What Happens If You Use the Wrong One

MistakeConsequence
Linear regression on a binary targetPredictions aren't bounded to [0,1] and aren't valid probabilities; the model also isn't optimized for a classification objective
Logistic regression on a continuous targetDoesn't apply directly — logistic regression's sigmoid output structurally cannot represent an unbounded continuous value

Common Mistakes

  • Assuming "regression" in both names means they're interchangeable or solve similar problems.
  • Using linear regression on a binary outcome and rounding predictions to 0 or 1 — technically possible but abandons calibrated probabilities and a proper classification-oriented cost function.

Interview Relevance

Q: "If both models compute z = wᵀx + b as a first step, what's fundamentally different about them?" What happens next: linear regression uses \(z\) directly as its prediction, while logistic regression passes \(z\) through the sigmoid to produce a bounded probability, and is trained with a different cost function (log-loss, not MSE) chosen specifically to keep that combination convex.

Practice Question

For each target, state whether you'd use linear or logistic regression: (a) predicted delivery time in hours, (b) whether a package will arrive late (yes/no), (c) customer satisfaction score on a continuous 0-100 scale.

Want to go beyond the notes?

Join Coding Now Tech Institute's Machine Learning course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Logistic Regression vs Linear Regression – FAQs

Quick answers about learning Logistic Regression vs Linear Regression in Machine Learning.

This free note from Coding Now Tech Institute explains Logistic Regression vs Linear Regression in Machine Learning — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Machine Learning topic on Coding Now Tech Institute, including Logistic Regression vs Linear Regression, is 100% free with no signup required.
With focused practice, most students grasp Logistic Regression vs Linear Regression in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now