Logistic Regression: Convert Log-Odds into Class Probabilities
Follow a one-feature logistic regression model from its linear score to probability, class decision and binary cross-entropy loss, with every step worked out.
KnowledgeGate Team
Exam prep & CS education

A linear model can return any real number, but a binary classifier needs a probability between 0 and 1 and, eventually, a class decision. A linear score becomes a probability through log-odds and the sigmoid, then a threshold turns that probability into a class. Binary cross-entropy measures the probability against the observed label. Practice sessions provide a toy feature; real learner performance depends on many variables, so this one-feature equation is not a student-evaluation system.
Why Logistic Regression Starts with a Linear Score
Let the binary target be y in {0, 1}. Logistic regression first forms a linear score:
z = b0 + b1x
Using z directly as a probability would fail. The score is unbounded, so it could be -7, 1.4 or 50, while a probability must remain in [0, 1].
Let x be the integer number of practice sessions completed, and let y = 1 mean that a learner clears a chosen mock-test benchmark. Suppose the fitted model is:
z = -4 + 1.2x
Practice sessions alone do not determine real learner performance; the equation isolates the relationship among linear score, probability, threshold and loss. The Skill Development Courses category places this toy calculation inside broader applied study.
Log-Odds Make the Linear Model Interpretable
For class-1 probability p, the odds and log-odds form this chain:
Odds:
p/(1-p)Log-odds, or logit:
ln(p/(1-p))Logistic model:
ln(p/(1-p)) = z = -4 + 1.2x
If that first conversion feels unfamiliar, revise the probability foundation for GATE CS.
The coefficient 1.2 has a precise meaning. One extra practice session adds 1.2 to the log-odds. Equivalently, it multiplies the odds by e^1.2 = 3.320. It does not add 1.2 to probability, and it certainly does not add 120 percentage points.
At x = 0, the score is z = -4, giving probability 1/(1 + e^4) = 0.0180. The inverse of the logit is the sigmoid:
p = sigma(z) = 1/(1 + e^(-z))
As z becomes very negative, p approaches 0. At z = 0, p is exactly 0.5. As z becomes very positive, p approaches 1. For any finite score, it reaches neither endpoint.
Worked Example: Turn Four Practice Sessions into a Probability
Set x = 4 and calculate each stage:
Linear score:
z = -4 + 1.2(4) = -4 + 4.8 = 0.8.Odds:
e^z = e^0.8 = 2.2255.Probability from odds:
p = 2.2255/(1 + 2.2255) = 0.6900.Direct sigmoid check:
p = 1/(1 + e^(-0.8)) = 0.6900.
So the toy model estimates a 0.6900 probability of class 1. It does not yet make a class decision.
Now reverse the calculation. From the rounded probability, p/(1-p) = 0.6900/0.3100 = 2.2258. Then ln(2.2258) = 0.8001, which returns the original score 0.8 up to rounding. This is why z is called the log-odds.
The same model produces:
Practice sessions | Score | Class-1 probability |
|---|---|---|
1 | -2.8 | 0.0573 |
2 | -1.6 | 0.1680 |
3 | -0.4 | 0.4013 |
4 | 0.8 | 0.6900 |
5 | 2.0 | 0.8808 |
Equal steps in x create equal steps of 1.2 in z, but not equal changes in probability. That non-linearity is the sigmoid doing its job.

A Decision Threshold Turns Probability into a Class
The probability model and decision rule are separate. For threshold t, predict class 1 when p >= t; otherwise predict class 0.
With t = 0.5, the sigmoid's monotonicity makes this equivalent to z >= 0. Solve the boundary:
-4 + 1.2x = 0, so x = 4/1.2 = 3.333.
Because x is an integer count, values of 4 or more predict class 1.
Now change only the threshold to t = 0.7. The required score is ln(0.7/0.3) = 0.8473, so:
x >= (0.8473 + 4)/1.2 = 4.0394
Among integer counts, class 1 now begins at x = 5. At x = 4, the probability remains 0.6900, but the predicted class changes from 1 to 0. Model fitting learns the coefficients. Threshold selection comes later and should use validation evidence plus the relative costs of false positives and false negatives. Neither 0.5 nor 0.7 is universally best.
Binary Cross-Entropy Measures How Wrong the Probability Was
For one example, binary cross-entropy is:
L = -[y ln(p) + (1-y) ln(1-p)]
It has two simple branches. If y = 1, then L = -ln(p). If y = 0, then L = -ln(1-p).
Continue with x = 4 and p = 0.6900:
If the observed label is
y = 1,L = -ln(0.6900) = 0.3711.If the observed label is
y = 0,L = -ln(0.3100) = 1.1712.
Training uses the probability and observed label, not the thresholded class. A confident error is punished more heavily. Predicting p = 0.9000 when y = 0 gives L = -ln(0.1000) = 2.3026. Across a dataset, training minimises the mean loss over examples.
Log-odds, sigmoid, thresholding and loss explain the fitted prediction. The GATE DA Machine Learning Revision Map separately works one gradient update that changes the model's weight and bias.

Common Logistic Regression Traps
Keep these distinctions clear:
A coefficient of
1.2is an additive change in log-odds. The corresponding odds multiplier is3.320. Neither is a fixed probability increase.Keep score
z, probabilitypand the thresholded class as three separate objects.Compute loss from
pandy, not from the final 0 or 1 class prediction.Do not apply the sigmoid again if a library method already returns probabilities.
State the tie rule. Here,
p >= tassigns a boundary case to class 1.High accuracy can hide class imbalance. Also, a sigmoid output is not automatically perfectly calibrated. Validation, threshold selection and calibration checks answer different questions.
How Exams and Interviews Test the Idea
Most short problems use one of four patterns:
Compute
pfrom coefficients and a givenx.Recover odds or log-odds from
p.Solve the feature-space decision boundary for a stated threshold.
Calculate binary cross-entropy for a given
(p, y)pair.
Try a quick oral check. At x = 4, does moving the threshold from 0.5 to 0.7 change the probability? No. It stays 0.6900; only the class changes. What does one extra session do? It multiplies the odds by 3.320, while the probability change depends on the starting point.
Short Version and the Next Step
Features create the linear score z. That score represents log-odds. The sigmoid converts it to probability p. A chosen threshold converts the probability to a class. During training, binary cross-entropy evaluates the probability against the observed label.
For a structured route through the wider model family and practical workflow, continue with Artificial Intelligence (AI). Then use Artificial Neural Networks MCQs with solved explanations to compare logistic regression with sigmoid-based neural outputs.
Keep learning
BPSC Teaching CS Weightage: Convert PYQ Evidence into Weekly Study Hours
Build a traceable syllabus-to-PYQ sheet, combine recurrence with your own accuracy, and turn the result into a resilient 16-hour weekly plan.
Regularised Regression: Ridge, Lasso and Elastic Net Compared with Worked Examples
Compare ridge, lasso and Elastic Net through two small, fully worked coefficient examples. Learn what each penalty does, how to tune it safely and where common interpretations fail.
Linear Regression: Fit a Least-Squares Line and Interpret Its Coefficients
Fit a least-squares line by hand, interpret both coefficients in context, and carry the same example through residuals, SSE, R-squared, diagnostics and self-checks.
Gradient Descent for Linear Regression: Derive and Run One Update by Hand
See prediction, residual, gradient and parameter update as one continuous calculation. Then verify the lower loss and test what an oversized learning rate does.





