MACHINE LEARNING/Student Engineering Notebook
Page 03·notes
LOGISTIC REGRESSION, K-NN, NAIVE BAYES & LDA—~30 MIN READ

Logistic Regression, Logit Link & Cross-Entropy Optimization

“Sigmoid mapping, maximum likelihood estimation, odds ratios, and linear decision boundaries.”

1.The Probabilistic Derivation of Logistic Regression

Unlike linear regression, which predicts an unbounded real value y in R, binary classification requires mapping predictions to the probability interval [0, 1].

Maximum Likelihood Estimation (MLE):

Assuming training examples are independently Bernoulli-distributed:

L(w) = Product_{i=1}^n p_i^{y_i} (1 - p_i)^{1 - y_i}.

Taking the natural log gives the Log-Likelihood:

ln L(w) = Sum_{i=1}^n [ y_i ln(p_i) + (1 - y_i) ln(1 - p_i) ].

Minimizing the negative log-likelihood per sample yields the Binary Cross-Entropy Loss function.

WORKED EXAM ANALYSIS · STEP-BY-STEP DERIVATION

2. Worked Practice Problem: Odds and Probability Calculation

⚠️ Pitfall Warning:

Do not confuse Odds = p / (1-p) with Probability p = Odds / (1 + Odds).

Problem: A logistic regression model outputs w^T x = 1.386 for an input instance. What are the predicted odds and probability p that the instance belongs to the positive class?

Step 1: Compute Odds:

Odds = e^{w^T x} = e^{1.386} ≈ 4.0

Step 2: Compute Probability p:

p = Odds / (1 + Odds) = 4 / (1 + 4) = 4 / 5 = 0.80 (80%).

Verification via Sigmoid:

sigma(1.386) = 1 / (1 + e^{-1.386}) = 1 / (1 + 0.25) = 1 / 1.25 = 0.80.

WORKED NUMERICAL · STUDENT DERIVATION✎ Key Takeaway: The decision boundary is w·x + b = 0, where p = 0.5.

Worked example: a logistic prediction and its loss

Problem Statement:
A logistic model gives z = w·x + b = 2 for an example whose true label is 1. Find the predicted probability and the cross-entropy loss.
Step 1: Sigmoid

p = 1/(1 + e^(−z)).

1/(1 + e^(−2))
↳ Result: ≈ 0.881
Step 2: Loss for y = 1

−ln p.

−ln 0.881
↳ Result: ≈ 0.127
Step 3: If the label were 0

−ln(1 − p) ≈ 2.13: a confident wrong answer costs much more.

Final Answer:p ≈ 0.881, loss ≈ 0.127
STUDENT PRACTICE · CONCEPT DRILL

Practice: test yourself

Original practice questions in the GATE style, with worked explanations. Not past-paper questions.

Problem 1 · GATE-LEVEL

What is the cross-entropy loss when the true label is 1 and the predicted probability is 0.8? Round to 3 decimal places.

Problem 2 · FOUNDATION

What is σ(0), the sigmoid at zero?

Problem 3 · GATE-LEVEL

Logistic regression is a linear classifier because:

SOURCE TRANSPARENCY & CITATIONS

Primary Academic References & Exam Sources

Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.

Curated University Lecture Series
Machine Learning: A Probabilistic Perspective ·
LECTURE SERIES