Linear Classification and Advanced Methods · Machine Learning

Logistic Regression

Watch lectures

Logistic Regression

1. Model

Linear score squashed to probability via sigmoid:

p=σ(s)=11+exp(−s)where s=wTx+bp = σ(s) = \frac{1}{1 + exp(-s)} \quad \text{where } s = w^{T}x + b

σ(s)→1σ(s) → 1 as s→∞s → ∞, →0→ 0 as s→−∞s → -∞, σ(0)=0.5σ(0) = 0.5.

2. Training (cross-entropy)

Minimize negative log-likelihood:

J=− mean of [ylogp+(1−y)log(1−p)]J = - \text{ mean of } [ y log p + (1-y) log (1-p) ]

Convex — gradient descent finds global optimum. Gradient: XT(p−y)/nX^{T}(p - y) / n.

3. Prediction

ypred=1 if p≥0.5 else 0y_{pred} = 1 \text{ if } p ≥ 0.5 \text{ else } 0

Boundary p=0.5p=0.5 ⟺ s=0s=0 (linear). Outputs are calibrated probabilities, not just labels.

4. Worked

s=2→p≈0.88s=2 → p ≈ 0.88 (confident positive). s=−1→p≈0.27s=-1 → p ≈ 0.27 (likely negative). Weight wi>0w_{i}>0 means feature ii pushes toward class 1.

5. Exam Points

  • Write sigmoid + loss — 7 marks, very frequent.
  • Why convex + probabilistic beats perceptron — 3 marks, frequent.
  • Threshold 0.5 rule — 2 marks.
AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.

← All Machine Learning modules