Logistic Regression Model and Hypothesis
What you'll learn: How logistic regression combines linear models with the sigmoid function to predict probabilities for binary classification.
The Core Idea
In linear regression, you learned to predict continuous values using a linear combination of features: w₁x₁ + w₂x₂ + ... + b. But for binary classification, you need outputs between 0 and 1 (representing probabilities).
The logistic regression hypothesis solves this by wrapping that linear combination inside a sigmoid function:
h(x) = sigmoid(w₁x₁ + w₂x₂ + ... + b)
Or more compactly:
h(x) = σ(wᵀx + b)
where σ is the sigmoid function you learned previously.
What This Means
The hypothesis transforms your input features through two stages:
- Linear stage: Compute
z = wᵀx + b(just like linear regression) - Non-linear transformation: Apply
σ(z) = 1 / (1 + e⁻ᶻ)to squeeze the output between 0 and 1
Think of it like this: The linear part (wᵀx + b) represents your model's "raw confidence score"—unbounded and potentially huge or negative. The sigmoid then converts this into a proper probability that the input belongs to class 1.
Example
If your model computes z = 3.2 for an email, σ(3.2) ≈ 0.96 means "96% probability this is spam." If z = -1.5, then σ(-1.5) ≈ 0.18 means "18% probability spam" (or 82% probability not spam).
Key Takeaway: The logistic regression hypothesis is h(x) = σ(wᵀx + b), combining a linear model with the sigmoid function to output probabilities for binary classification tasks.