Skip to Content

Logistic Regression

Start writing here...

Absolutely! Logistic Regression is a popular algorithm used for classification, not regression—despite its name!

🔐 What is Logistic Regression?

Logistic regression models the probability that a given input belongs to a particular class (typically binary: 0 or 1) by using a sigmoid function to output values between 0 and 1.

📊 Use Case Example:

  • Email classification: Spam (1) or Not Spam (0)
  • Disease prediction: Sick (1) or Healthy (0)

🔹 Model Formula:

It starts like linear regression:

z=w1x1+w2x2+⋯+wnxn+bz = w_1x_1 + w_2x_2 + \dots + w_nx_n + b

Then applies the sigmoid function:

y^=σ(z)=11+e−z\hat{y} = \sigma(z) = \frac{1}{1 + e^{-z}}

Where:

  • y^\hat{y} is the predicted probability (between 0 and 1)
  • If y^>0.5\hat{y} > 0.5, classify as 1; otherwise, 0

🔸 Loss Function:

  • Uses Binary Cross-Entropy (Log Loss):

Loss=−[ylog⁡(y^)+(1−y)log⁡(1−y^)]\text{Loss} = -\left[y \log(\hat{y}) + (1 - y) \log(1 - \hat{y})\right]

Pros:

  • Simple and fast
  • Outputs probabilities
  • Interpretable coefficients
  • Works well with linearly separable data

Cons:

  • Assumes linear decision boundary
  • Doesn’t perform well on complex or non-linear problems without feature engineering or transformation

📦 Extensions:

  • Multinomial Logistic Regression: For multi-class problems
  • Regularized Logistic Regression: Adds L1 (Lasso) or L2 (Ridge) to prevent overfitting

Would you like a visual of the sigmoid function or a 2D decision boundary example?