Linear regression predicts a continuous numeric value with a straight-line model; logistic regression predicts the probability of a class (usually yes/no) by passing a linear combination through the sigmoid function, so it is used for classification.
Linear regression
\[\hat y = \beta_0 + \beta_1x_1 + \dots + \beta_nx_n\]
Output can be any real number. Fitted by minimising the sum of squared errors (ordinary least squares). Example: predicting house price from area.
Logistic regression
\[p = \sigma(z) = \frac{1}{1 + e^{-z}},\quad z = \beta_0 + \beta_1x_1 + \dots\]
Output is between 0 and 1 and is read as \(P(y = 1)\); a threshold (often 0.5) gives the class. Fitted by maximum likelihood (minimising log-loss / cross-entropy). Example: predicting whether an email is spam.
| Point | Linear regression | Logistic regression |
|---|---|---|
| Task | Regression | Classification |
| Output | Continuous value \((-\infty, \infty)\) | Probability in (0, 1), then class |
| Function | Straight line / hyperplane | S-shaped sigmoid curve |
| Loss / fitting | Mean squared error, least squares | Log-loss, maximum likelihood |
| Target variable | Numeric | Categorical (binary; multinomial for more classes) |
| Coefficient meaning | Change in \(y\) per unit change in \(x\) | Change in log-odds \(\ln\frac{p}{1-p}\) per unit change in \(x\) |
| Evaluation | MSE, RMSE, \(R^2\) | Accuracy, precision, recall, ROC-AUC |
| Example | Predict salary, temperature, sales | Predict pass/fail, disease/no disease |
Using linear regression for a yes/no target is a poor idea because it can predict values below 0 or above 1 and is badly affected by outliers; the sigmoid in logistic regression avoids this.