ML0048 Logistic Regression

Can you explain logistic regression and how it contrasts with linear regression?

Answer

Logistic regression maps inputs to a probability space for classification, while linear regression estimates continuous outcomes through a direct linear relationship. Logistic regression estimates the probability that a binary outcome (y = 1) occurs given an input vector \mathbf{x}, by passing a linear score through the sigmoid function; the output lies between 0 and 1 and is interpreted as the probability of class membership. Note that standard logistic regression is still fundamentally a linear model at its core: it cannot model non-linear relationships directly.

(1) Purpose: Linear regression predicts a continuous output (price, height); logistic regression predicts a probability for classification (spam or not).
(2) Output Range: Linear regression emits any real number (can be negative or above 1); logistic regression squashes to (0, 1) with the sigmoid.
(3) Assumption: Linear regression assumes a linear input-output relationship; logistic regression assumes a linear relationship between inputs and the log-odds of the positive class.

Left panel linear regression line fitting continuous data, right panel sigmoid curve fitting binary zero one data with a 0.5 decision boundary

Figure 1: The contrast in one picture: linear regression fits a straight line through continuous targets (left); logistic regression fits an S-shaped sigmoid to 0/1 labels (right), with the 0.5 probability level acting as the decision boundary.

Mathematical Formulation:
\Pr(y = 1 \mid \mathbf{x}) = \frac{1}{1 + e^{-(\mathbf{w}^{\top} \mathbf{x} + b)}}

Where:

  • \mathbf{x} is the input feature vector.
  • \mathbf{w} is the weight vector and b the bias; the linear score \mathbf{w}^{\top}\mathbf{x} + b is the log-odds of the positive class.
  • The sigmoid maps the score to (0, 1); classifying at threshold 0.5 gives a linear decision boundary.
FeatureLogistic RegressionLinear Regression
Type of ProblemClassificationRegression
Dependent VariableCategorical (e.g., Yes/No, 0/1, True/False)Continuous (e.g., Price, Temperature, Age)
OutputProbability (0 to 1)Real number (any value)
Core FunctionSigmoid function (for binary)Identity function
Loss FunctionLog-loss (Cross-entropy)Mean Squared Error (MSE)

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *