Unit 5 · Tutorial 02
Probability and the Sigmoid Function
T-01 showed why a straight line cannot classify. This tutorial builds the replacement: a function that takes any real-valued score and squashes it into a probability between 0 and 1, smoothly, monotonically, and with a principled interpretation in terms of odds.
01 Learning objectives
By the end of this tutorial you will be able to
- Explain why a linear model is unsuitable for binary classification, in terms of both output range and interpretation.
- Define the sigmoid function and describe its shape, range, symmetry and limiting behaviour.
- Convert between probability, odds and log-odds, and explain why log-odds is the natural scale for a linear model.
- Compute a predicted probability from a set of features, coefficients and an intercept.
- Interpret a logistic regression coefficient as a multiplicative change in odds.
Position in the unit
This tutorial supplies the mathematical core of logistic regression. T-03 uses the probability output to draw decision boundaries; T-04 explains how the coefficients are actually estimated; T-05 develops the odds interpretation in more depth. Everything in the rest of the unit rests on the material here.
02 Motivating example
A bank is building a model to decide whether to approve loan applications. For each applicant the bank holds a credit score, a debt-to-income ratio, and a handful of other variables. The decision is binary — approve or decline — but the bank is not really interested in a binary answer. It is interested in a probability.
Why? Because a probability can be used for far more than a yes/no decision:
- Pricing. An applicant with a 6% probability of default might receive a different interest rate than one with a 2% probability, even though both are approved.
-
Threshold setting. The bank can choose where to draw the
line between approve and decline, and can move that line depending on its
appetite for risk — a decision that is impossible if the model only ever
emits
TrueorFalse. - Ranking and review. Applications near the threshold can be sent to a human underwriter, while those far from it are auto-processed.
- Regulatory explanation. "Your application was declined because the estimated probability of default was 0.71" is a far more defensible statement than "the model said no."
Suppose a colleague suggests the obvious approach: fit a linear regression to the binary outcome, where default is coded as 1 and repayment as 0. The predicted value is then interpreted as a probability. On the surface this seems reasonable — the model is linear, the coefficients are interpretable, and the machinery is already familiar from Unit 4.
It does not work. The next section explains precisely why, and what replaces it.
The failure mode to watch for
A linear model fitted to binary data will happily predict a probability of
−0.3 for one applicant and 1.4 for another.
Neither number means anything. Worse, the model will be most confident —
and most wrong — for the applicants it should be most careful about: those
at the extremes of the feature range.
03 Concept explanation
3.1 Why linear regression fails at classification
Three problems, in increasing order of severity.
The range problem. A linear function
z = β₀ + β₁x₁ + … + βₚxₚ takes values on the whole real line.
A probability must lie in [0, 1]. Nothing in the linear model
constrains its output, so any prediction outside the unit interval is
meaningless.
The shape problem. Even when a linear fit happens to stay
inside [0, 1] for the observed data, its behaviour at the edges
is wrong. Probabilities do not change at a constant rate: they saturate. An
applicant with a credit score of 620 and one with 640 differ meaningfully in
risk; an applicant with 800 and one with 820 barely differ at all, because
both are already near-certain to repay. A straight line cannot express this
saturation.
The statistical problem. Linear regression assumes errors are
normally distributed with constant variance. For a binary outcome, the error
can only take two values at each point, and its variance depends on the
predicted probability — it is largest when p = 0.5 and shrinks
to zero as p approaches 0 or 1. The assumptions are simply
violated, which means the coefficients are estimated inefficiently and the
standard errors are wrong.
A useful way to remember this
Linear regression models a quantity — a price, a temperature, a duration — that can sensibly take any value on a line. Classification models a decision under uncertainty, and uncertainty does not behave linearly. It compresses towards the extremes.
3.2 The idea: keep the linear part, transform the output
The linear model is not useless — it is just being asked to do the wrong job. What it is genuinely good at is producing a score: a single number that summarises the evidence, higher meaning "more likely to be positive." What we need is a way to turn that score into a probability.
So we split the model into two stages:
Stage 1 — linear score: z = β₀ + β₁x₁ + β₂x₂ + … + βₚxₚ
Stage 2 — squash to [0,1]: p = σ(z)
The function σ is the sigmoid, also called the
logistic function. The full model is
p = σ(β₀ + β₁x₁ + … + βₚxₚ), and it is called — unsurprisingly —
logistic regression. The name is a historical accident: it is a
classification model, despite containing the word "regression."
3.3 The sigmoid function
The sigmoid is defined as:
σ(z) = 1 / (1 + e^(−z))
Its properties are exactly what classification requires:
| Property | Statement | Why it matters |
|---|---|---|
| Range | 0 < σ(z) < 1 for all real z |
The output is always a valid probability |
| Monotonic | Strictly increasing in z |
More evidence never lowers the probability |
| Midpoint | σ(0) = 0.5 |
Zero score means maximum uncertainty |
| Symmetry | σ(−z) = 1 − σ(z) |
Flipping the sign flips the probability |
| Saturation | σ(z) → 0 as z → −∞; σ(z) → 1 as z → +∞ |
Extreme evidence produces confident but bounded predictions |
| Smooth | Infinitely differentiable everywhere | The model can be fitted by gradient-based optimisation |
The sigmoid has the familiar S-shape: nearly flat at both ends, steepest in the middle. That flatness at the extremes is precisely the saturation behaviour that linear regression could not produce.
3.4 The logit — running the sigmoid backwards
Because the sigmoid is strictly increasing, it has an inverse. Rearranging
p = 1 / (1 + e^(−z)) gives:
z = log( p / (1 − p) )
This quantity has a name. The ratio p / (1 − p) is the
odds, and its logarithm is the log-odds or
logit.
This is the key insight of the whole tutorial: logistic regression is a linear model in the log-odds. The model says that
log( p / (1 − p) ) = β₀ + β₁x₁ + … + βₚxₚ
which is a genuinely linear statement — just not on the scale you might have expected. The linearity lives on the log-odds scale, and the sigmoid is the bridge back to probabilities.
Two scales, one model
On the log-odds scale the model is linear: each feature contributes a fixed additive amount. On the probability scale the model is a curve: the same fixed contribution in log-odds produces a smaller change in probability when the probability is already near 0 or 1. Both statements describe the same model — they are just different views of it.
3.5 Probability, odds and log-odds
These three ways of expressing the same thing appear constantly in logistic regression, and mixing them up is the most common source of confusion. The table below sets them side by side.
| Scale | Formula | Range | Example (p = 0.75) |
|---|---|---|---|
| Probability | p |
[0, 1] |
0.75 |
| Odds | p / (1 − p) |
[0, ∞) |
3 — "3 to 1 in favour" |
| Log-odds | log( p / (1 − p) ) |
(−∞, ∞) |
1.099 |
Notice the pattern in the ranges. Probability is bounded above and below; odds are bounded below but not above; log-odds are unbounded in both directions. Only the log-odds scale can be modelled by an unrestricted linear function, which is exactly why the model is expressed there.
3.6 Interpreting the coefficients
Because the model is linear in log-odds, a coefficient βⱼ has a
clean interpretation:
-
On the log-odds scale: a one-unit increase in
xⱼ, holding all other features constant, increases the log-odds byβⱼ. -
On the odds scale: the odds are multiplied by
e^(βⱼ)— the odds ratio. -
Sign:
βⱼ > 0means the feature increases the probability of the positive class;βⱼ < 0means it decreases it;βⱼ = 0means no effect.
The odds-ratio interpretation is worth internalising. A coefficient of
0.693 corresponds to an odds ratio of
e^0.693 ≈ 2 — the odds double for each one-unit increase. A
coefficient of −1.386 corresponds to
e^(−1.386) ≈ 0.25 — the odds fall to a quarter.
The most common interpretation error
A positive coefficient does not mean "this feature increases the
probability by βⱼ." Coefficients live on the log-odds scale.
The effect on the probability itself depends on where on the curve you
currently are — it is large near p = 0.5 and tiny near
p = 0 or p = 1.
04 Visual illustration
The figure below plots the sigmoid function. Read it carefully — almost everything in the rest of this unit can be understood by referring back to it.
z runs along the horizontal axis; the resulting probability
σ(z) runs up the vertical axis. Note the two flat regions at
the extremes — this is the saturation that linear regression cannot
reproduce.
Reading the curve
Three features of the plot are worth pointing out explicitly.
The middle is steep. Around z = 0, a small
change in the score produces a relatively large change in probability. This
is the region of genuine uncertainty, where additional evidence is most
informative.
The ends are flat. By z = −4 the curve is
already almost touching zero; by z = 4 it is almost touching
one. Additional evidence in these regions changes the probability very
little — the model is already confident.
The output never reaches the limits. However large
z becomes, σ(z) never equals exactly 0 or exactly 1.
This is a feature, not a limitation: it means the model never claims absolute
certainty, and it keeps the mathematics well-behaved (in particular, the
log-odds never become infinite).
The table below gives numerical values for the curve, which are useful when you want to estimate a sigmoid by hand.
| z | σ(z) | Interpretation |
|---|---|---|
| −4 | 0.018 | Very unlikely |
| −2 | 0.119 | Unlikely |
| −1 | 0.269 | Somewhat unlikely |
| 0 | 0.500 | Maximum uncertainty |
| 1 | 0.731 | Somewhat likely |
| 2 | 0.881 | Likely |
| 4 | 0.982 | Very likely |
Notice the symmetry: σ(−2) = 0.119 and
σ(2) = 0.881, and 0.119 + 0.881 = 1. This is the
identity σ(−z) = 1 − σ(z) in action.
05 Worked example
We will work through two examples. The first uses a single feature so that the arithmetic is easy to follow; the second returns to the loan application from Section 02 and uses two features.
Worked example 1 · One feature
A tutoring centre wants to predict whether a student will pass an exam based on the number of hours of tutoring they attend. A logistic regression fitted to past data gives:
z = −3 + 1.2 × hours
So β₀ = −3 and β₁ = 1.2. The predicted probability
of passing is p = σ(z).
Step 1 — compute the linear score for each student.
For a student with 3 hours of tutoring:
z = −3 + 1.2 × 3 = −3 + 3.6 = 0.6
Step 2 — apply the sigmoid.
p = 1 / (1 + e^(−0.6))
= 1 / (1 + 0.5488)
= 1 / 1.5488
= 0.6457
The model predicts a 64.6% probability of passing.
Step 3 — repeat for a range of values.
| Hours | z = −3 + 1.2 × hours | p = σ(z) | Predicted outcome |
|---|---|---|---|
| 0 | −3.0 | 0.047 | Very unlikely to pass |
| 1 | −1.8 | 0.142 | Unlikely to pass |
| 2 | −0.6 | 0.354 | Leaning towards fail |
| 3 | 0.6 | 0.646 | Leaning towards pass |
| 4 | 1.8 | 0.858 | Likely to pass |
| 5 | 3.0 | 0.953 | Very likely to pass |
Step 4 — interpret the coefficient.
The coefficient β₁ = 1.2 lives on the log-odds scale. On the
odds scale, each additional hour of tutoring multiplies the odds of passing
by:
e^1.2 ≈ 3.32
So each extra hour of tutoring roughly triples the odds of
passing. Note carefully that it does not triple the probability.
A student at p = 0.142 moves to p = 0.354 — a
large jump. A student at p = 0.858 moves to
p = 0.953 — a much smaller one in absolute terms, even though
the odds multiplier is identical.
Step 5 — check the halfway point.
At what number of hours does the model predict a 50% probability? Setting
z = 0:
−3 + 1.2 × hours = 0
hours = 3 / 1.2 = 2.5
A student with 2.5 hours of tutoring sits exactly on the fence. This value — the point where the score crosses zero — will become important in T-03, when we draw decision boundaries.
Worked example 2 · Two features — the loan application
Returning to the bank from Section 02. A logistic regression fitted to historical loan data gives:
z = −12 + 0.015 × credit_score + 5 × debt_to_income
where debt_to_income is expressed as a fraction (so 0.45 means
45% of income goes to debt servicing).
Applicant A: credit score 600, debt-to-income 0.45.
z = −12 + 0.015 × 600 + 5 × 0.45
= −12 + 9.0 + 2.25
= −0.75
p = σ(−0.75)
= 1 / (1 + e^(0.75))
= 1 / (1 + 2.117)
= 0.321
Applicant B: credit score 750, debt-to-income 0.20.
z = −12 + 0.015 × 750 + 5 × 0.20
= −12 + 11.25 + 1.00
= 0.25
p = σ(0.25)
= 1 / (1 + e^(−0.25))
= 1 / (1 + 0.7788)
= 0.562
Applicant C: credit score 820, debt-to-income 0.10.
z = −12 + 0.015 × 820 + 5 × 0.10
= −12 + 12.30 + 0.50
= 0.80
p = σ(0.80)
= 1 / (1 + e^(−0.80))
= 1 / (1 + 0.4493)
= 0.690
The three applicants receive predicted probabilities of roughly 0.32, 0.56 and 0.69. A bank applying a 0.50 threshold would decline A and approve B and C — but it could equally set the threshold at 0.60, in which case B would also be declined, or send B to manual review precisely because it sits close to the boundary.
Interpreting the coefficients.
-
β₁ = 0.015for credit score. Each additional point of credit score multiplies the odds bye^0.015 ≈ 1.0151— about a 1.5% increase in odds per point. Over 100 points that compounds toe^1.5 ≈ 4.48, so a 100-point improvement roughly quadruples the odds. -
β₂ = 5for debt-to-income. Each additional 0.10 in the debt-to-income ratio multiplies the odds bye^0.5 ≈ 1.65. Going from 0.20 to 0.45 — a change of 0.25 — multiplies the odds bye^1.25 ≈ 3.49. -
β₀ = −12is the log-odds of default for an applicant with zero credit score and zero debt. That combination is not physically meaningful, so the intercept is best treated as a baseline adjustment rather than something to interpret substantively.
Sanity-check your arithmetic
After Computing a probability, verify it lies between 0 and 1 and moves in
the expected direction. In the examples above, raising the credit score and
lowering the debt-to-income ratio both increased the probability, which
matches the positive and negative coefficients respectively. If a
calculation produces a probability outside [0, 1], you have
almost certainly forgotten to apply the sigmoid.
06 Interactive activity
Activity · Explore the sigmoid
Work through the following steps using a calculator, a spreadsheet, or a few lines of Python. The goal is to build intuition for how the sigmoid behaves, not to produce a polished artefact.
-
Compute
σ(z)forz = −6, −4, −2, −1, 0, 1, 2, 4, 6. Record the values in a table. -
For each pair
(z, −z), verify that the two probabilities sum to 1. -
Compute the difference
σ(1) − σ(0)and the differenceσ(5) − σ(4). Both involve a one-unit change inz. How do the two differences compare? -
Now consider a model
z = −3 + 1.2 × hoursas in Worked Example 1. Compute the probability of passing for 0 through 6 hours in steps of 0.5, and plot the result. -
Change the coefficient from
1.2to0.3and re-plot. What happens to the steepness of the curve? What does a smaller coefficient mean about the feature's effect? -
Finally, change the intercept from
−3to+3and re-plot. What happens to the curve? Which feature would such a change correspond to in a real model?
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(z):
return 1 / (1 + np.exp(-z))
z = np.linspace(-6, 6, 400)
fig, ax = plt.subplots(figsize=(7, 4.5))
ax.plot(z, sigmoid(z), linewidth=2.5, color="#1f4e8c")
ax.axhline(0.5, color="#cfdff2", linestyle="--", linewidth=1.2)
ax.axvline(0.0, color="#cfdff2", linestyle="--", linewidth=1.2)
ax.set_xlabel("linear score z")
ax.set_ylabel("probability σ(z)")
ax.set_ylim(-0.05, 1.05)
ax.grid(alpha=0.25)
plt.tight_layout()
plt.show()
# Vary the slope coefficient
for beta in [0.3, 0.8, 1.2, 2.0]:
hours = np.linspace(0, 6, 200)
z = -3 + beta * hours
ax.plot(hours, sigmoid(z), label=f"β₁ = {beta}")
ax.legend()
When you vary β₁, you are changing how steeply the probability
rises with each hour of tutoring. When you vary β₀, you are
shifting the whole curve left or right. Those two operations — steepness and
position — are all a logistic regression can do with a single feature, and
they correspond exactly to the two coefficients.
07 Self-check questions
Answer each question before revealing the solution. If you get one wrong, re-read the relevant subsection rather than simply moving on.
Question 1
Why can a linear regression not be used directly to predict a probability?
Show answer
Three reasons. First, its output range is the whole real line, so it
can predict values outside [0, 1], which are not valid
probabilities. Second, it models a constant rate of change, whereas
probabilities saturate near 0 and 1. Third, its statistical
assumptions — normally distributed errors with constant variance — are
violated by a binary outcome, whose variance depends on the predicted
probability.
Question 2
What is σ(0), and why is that value meaningful?
Show answer
σ(0) = 0.5. A linear score of zero means the evidence
for and against the positive class is exactly balanced, so the model
is maximally uncertain. On the odds scale, a score of zero corresponds
to odds of 1 — an even bet.
Question 3
A model predicts p = 0.8. What are the odds? What is the
log-odds?
Show answer
Odds = p / (1 − p) = 0.8 / 0.2 = 4. The event is four
times as likely to occur as not.
Log-odds = log(4) ≈ 1.386. This is the value
z that the linear part of the model would have produced.
Question 4
A logistic regression has coefficient β₁ = −0.5 for a
feature x₁. Interpret this coefficient.
Show answer
Holding other features constant, a one-unit increase in
x₁ decreases the log-odds by 0.5. On the odds scale, the
odds are multiplied by e^(−0.5) ≈ 0.607 — a reduction of
about 39%. The negative sign means higher values of the feature are
associated with a lower probability of the positive class.
Question 5
Two students have predicted pass probabilities of 0.10 and 0.80. Each gains one hour of tutoring. Which student's probability increases more?
Show answer
With β₁ = 1.2, the odds are multiplied by
e^1.2 ≈ 3.32 in both cases — but the probability
changes very differently.
-
Starting at
p = 0.10: odds= 0.111. New odds= 0.369, givingp ≈ 0.270. An increase of about 0.17. -
Starting at
p = 0.80: odds= 4.0. New odds= 13.28, givingp ≈ 0.930. An increase of about 0.13.
The student starting at 0.10 gains more in probability terms, because the curve is steeper in that region. The odds multiplier is identical; the probability change is not. This is the central point of Section 3.6.
Question 6
Why does the sigmoid never output exactly 0 or exactly 1, and why is that desirable?
Show answer
Because e^(−z) is always strictly positive, the
denominator 1 + e^(−z) is always strictly greater than 1,
so σ(z) never quite reaches 0 or 1.
This is desirable for two reasons. Statistically, a model should not claim absolute certainty from finite evidence. Mathematically, if the probability were exactly 0 or 1, the log-odds would be infinite, and the fitting procedure — which works on the log-odds scale — would break down.
08 Practice exercises
These exercises build fluency with the mechanics. Work them by hand first; then check your answers computationally.
-
Compute
σ(z)to three decimal places forz = −3, −1.5, −0.5, 0, 0.5, 1.5, 3. Verify the symmetry property for each pair. -
Convert each of the following probabilities to odds and then to log-odds:
0.05,0.25,0.50,0.75,0.95. What do you notice about the log-odds of complementary probabilities? -
A model has the form
z = −2 + 0.8x. Compute the predicted probability forx = 0, 1, 2, 3, 4, 5. At what value ofxdoes the model predict exactly 0.5? -
A coefficient is estimated as
β = 2.303. What is the odds ratio? What approximate percentage change in odds does a one-unit increase in the feature produce? -
A model predicts
p = 0.92for a particular case. What is the corresponding linear scorez? (Hint: apply the logit.) -
Two features have coefficients
β₁ = 0.4andβ₂ = −1.2. By how much does the log-odds change whenx₁increases by 3 andx₂decreases by 0.5? - Using the loan model from Worked Example 2, compute the predicted probability for an applicant with credit score 680 and debt-to-income 0.35. Would this applicant be approved at a threshold of 0.5? At a threshold of 0.6?
-
Sketch, without plotting software, the curves corresponding to
z = −4 + 2xandz = −1 + 0.5x. Describe how they differ in steepness and position, and explain what each difference means in terms of the feature's effect.
09 Problem sets
These problems require more than mechanical calculation. They ask you to reason about model behaviour, interpret results in context, and identify errors in reasoning.
Problem 1 · Diagnosing a modelling error
A colleague fits a logistic regression and reports that "increasing the
credit score by 10 points raises the probability of repayment by 4
percentage points." The coefficient for credit score is
β = 0.004. Identify what is wrong with the statement and
rewrite it correctly.
Problem 2 · The saturation effect in practice
A medical screening model has the form
z = −5 + 0.04 × biomarker. A clinician proposes raising the
biomarker measurement precision, arguing that "more precise measurements
will always improve the model." For a patient whose biomarker reading is
already 300, how much would the predicted probability change if the reading
were 310 instead? What does your answer imply about the clinician's
proposal?
Problem 3 · Choosing a scale
A stakeholder asks you to explain a model's behaviour. You can present the results on the probability scale, the odds scale, or the log-odds scale. For each of the following audiences, choose a scale and justify your choice: (a) a patient deciding whether to undergo a screening test; (b) a hospital administrator setting a referral threshold; (c) a statistician auditing the model's coefficients.
Problem 4 · Two features, one curve
Consider a model with two features where
β₁ = 1.0 and β₂ = −1.0. Describe the set of all
points (x₁, x₂) for which the model predicts exactly
p = 0.5. What shape does this set have? How does your answer
relate to the material you will meet in T-03?
Problem 5 · Intercept or coefficient?
A model is refitted on a new dataset in which a feature has been rescaled — for example, debt-to-income is now expressed as a percentage (45) rather than a fraction (0.45). Which coefficients change, and by how much? Which coefficient is unchanged? Explain your reasoning, then verify it by constructing a small example.
Problem 6 · Beyond the sigmoid
The sigmoid is one function that maps the real line to (0, 1).
Suggest at least one other function with the same property, and explain what
practical difference it would make if a model used it instead of the
sigmoid. (You may wish to consider the probit function, which uses
the cumulative distribution function of the standard normal distribution.)
10 Discussion and projects
Discussion questions
- Logistic regression is often described as a linear model, despite producing a non-linear relationship between features and probability. Is this description misleading? Defend your answer.
- The sigmoid saturates, meaning that beyond a certain point additional evidence produces almost no change in predicted probability. Is this a desirable property for a decision-making system, or does it risk the model ignoring genuinely important information at the extremes?
- Probabilities are often collapsed to a binary decision by applying a threshold. In what sense is the threshold a separate modelling choice from the logistic regression itself, and who should be responsible for setting it?
-
The intercept term
β₀is frequently uninterpretable in practical terms, because it corresponds to a case where every feature is zero. Should models include an intercept at all? What would happen if they did not?
Mini-project · Calibration in practice
In this project you will investigate whether a logistic regression's predicted probabilities are actually reliable — a property called calibration.
Use a public binary classification dataset, or synthesise one with a known generating process.
Use LogisticRegression from scikit-learn. Record the predicted probabilities on a held-out test set.
Group the predictions into deciles — for example, all cases with predicted probability between 0.2 and 0.3.
For each bin, compute the mean predicted probability and the actual observed positive rate.
A perfectly calibrated model lies on the diagonal. Where does yours deviate?
If the model is poorly calibrated, what does that mean for a decision-maker who trusts the probabilities at face value?
Calibration is a topic that appears again in Unit 6 (Model Evaluation) and in Unit 19 (Governance & Fairness), where it becomes entangled with the impossibility results for group fairness metrics. A model that is well calibrated overall may still be miscalibrated for a subgroup — and that difference has real consequences.
11 Summary
This tutorial built the core of logistic regression: the machinery that turns a linear score into a probability.
- Linear regression cannot classify. Its output range, constant rate of change, and statistical assumptions are all wrong for a binary outcome.
-
The fix is a two-stage model. Compute a linear score
z = β₀ + β₁x₁ + … + βₚxₚ, then squash it through the sigmoidσ(z) = 1 / (1 + e^(−z)). -
The sigmoid has the right properties. It is bounded in
(0, 1), strictly increasing, symmetric aroundσ(0) = 0.5, smooth, and saturating at both ends. -
Logistic regression is linear in the log-odds. The inverse
of the sigmoid is the logit:
log(p / (1 − p)) = z. This is the scale on which the model is genuinely linear. -
Probability, odds and log-odds are three views of one quantity.
Their ranges are
[0, 1],[0, ∞)and(−∞, ∞)respectively — which is why only the last can be modelled by an unrestricted linear function. -
Coefficients act multiplicatively on the odds. A one-unit
increase in
xⱼmultiplies the odds bye^(βⱼ). The effect on the probability depends on where on the curve you are.
Before moving to T-03
You should be able to take a set of coefficients, a set of feature values, and compute a predicted probability without referring back to this page. You should also be able to explain, in one sentence, why the model is described as linear even though its probability output is a curve.
12 Further reading
Core
- James, Witten, Hastie & Tibshirani — An Introduction to Statistical Learning, Chapter 4. The standard treatment of logistic regression, with clear derivations and worked examples. Section 4.3 covers the material in this tutorial directly.
- scikit-learn documentation — LogisticRegression. Read the "Mathematical formulation" section alongside this tutorial. It presents the model in precisely the terms developed here.
- Hastie, Tibshirani & Friedman — The Elements of Statistical Learning, Section 4.4. A more advanced treatment, including the link to generalised linear models and the derivation of the fitting procedure you will meet in T-04.
Supplementary
- Gelman, Hill & Vehtari — Regression and Other Stories, Chapters 13–14. An accessible treatment of logistic regression with a strong emphasis on interpretation and on presenting results to non-technical audiences.
- Hosmer, Lemeshow & Sturdivant — Applied Logistic Regression. A comprehensive reference covering diagnostics, goodness-of-fit and the practical issues that arise in real applications.
- Niculescu-Mizil & Caruana — "Predicting Good Probabilities with Supervised Learning" (ICML 2005). The classic empirical study of calibration across model families, directly relevant to the mini-project in Section 10.
On the history
- Cramer, J.S. — "The Origins of Logistic Regression" (2002). A short historical account of how the logistic function came to be used for binary outcomes — and why the model carries the confusing name it does.