Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to Machine Learning Notes
Topic #807

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, , 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.

Related ML Notes

Want to go beyond the notes?

Join CodingNow's Machine Learning course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →