Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Only allowed to go up
Some quantities can only rise with their input: a detector’s reading as light gets brighter, or a material’s damage as dose increases. Noisy data may wiggle down here and there, but the truth does not. Isotonic regression finds the closest curve to the data that never goes down. Wherever the data dip, it flattens them into a step at their average. You don’t choose a formula; “never decreasing” is the only rule.
Calibration curves for sensors, detectors and actuators are monotone but often have knees and plateaus (saturation, dead zones). Isotonic regression fits them without guessing a functional form. It is also the standard way to turn classifier scores into calibrated probabilities (D0.10).
- 1. An isotonic fit is…
- 2. Where the data dip, the isotonic fit…
- 3. Isotonic regression needs you to choose…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.PAVA by hand
Data in x order: y = 3, 4, 1, 5.
| Step | Blocks (mean, size) | Action |
|---|---|---|
| add 3 | (3, 1) | |
| add 4 | (3, 1), (4, 1) | 4 ≥ 3: fine |
| add 1 | (3, 1), (4, 1), (1, 1) | 1 below 4: violation |
| pool | (3, 1), (2.5, 2) | 2.5 below 3: violation again |
| pool | (2.667, 3) | (3 + 4 + 1)/3 |
| add 5 | (2.667, 3), (5, 1) | fine |
The fit is 2.667, 2.667, 2.667, 5. Its squared error is 0.111 + 1.778 + 2.778 + 0 = 4.667. No other non-decreasing sequence does better.
The steps in plain English:
- Sort the data by x (average y over tied x values, with weights).
- Go left to right, starting a new block for each point.
- While the newest block’s mean is below the previous block’s, merge them into one block at their weighted mean.
- At the end, each point’s fitted value is its block’s mean.
- To predict between training x values, interpolate (scikit-learn: linearly) and hold constant beyond the ends.
- 1. PAVA fit of 1, 3, 2, 4?
- 2. PAVA fit of 5, 4, 3, 2, 1?
- 3. A pooled block's level is…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.The problem and the algorithm
Problem: minimise Σ wᵢ(yᵢ − fᵢ)² subject to f₁ ≤ f₂ ≤ … ≤ fₙ (points in x order). This is a quadratic program with a convex feasible set, so it has a unique solution.
PAVA. The algorithm keeps a stack of blocks with mean, weight and size. When a block is pushed, it is merged with the top of the stack while the order is violated. Each merge removes one block, so there are at most n − 1 merges: O(n) time, plus O(n log n) to sort.
Ties in x are handled by first averaging the y values at each distinct x, with the counts as weights.
Properties:
- The fit is a step function. Its levels are means of consecutive data runs.
- The fit preserves the weighted mean of y.
- The fit is scale- and shift-equivariant.
from sklearn.isotonic import IsotonicRegression
iso = IsotonicRegression(increasing=True, out_of_bounds="clip").fit(x, y)
iso.predict(x_new) # piecewise-linear between fitted points, clipped outside
from sklearn.calibration import CalibratedClassifierCV
CalibratedClassifierCV(clf, method="isotonic", cv=5) # classifier probability calibrationUse it when monotonicity is known from physics or logic and the shape is otherwise unknown. Be careful with small samples (the steps are coarse and overfit) and with extrapolation (the fit is flat beyond the data).
- 1. PAVA runs in…
- 2. For a decreasing fit you can…
- 3. Beyond the training range, scikit-learn's isotonic fit (clip) is…
Level 3: Advanced
★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.Why it works, and how fast
Optimality (KKT). Within each block, the fitted level is the block mean, so the residuals in each block sum to zero. Between blocks, the constraints are active only where pooling occurred. One can show that every prefix of each block has a mean at least the block mean. This gives non-negative Lagrange multipliers, so the KKT conditions hold. Since the problem is convex, the KKT point is the global optimum.
Projection view. The monotone sequences form a convex cone. Isotonic regression is the Euclidean projection of y onto this cone, so it is non-expansive and unique.
Rates.
- For a monotone f with bounded variation, the isotonic MSE decreases like n^(−2/3), with no smoothness assumption. Exercise 2 measures a log–log slope of −0.66.
- Smooth parametric fits converge like n⁻¹ if the model is correct. Otherwise they stall at their bias, which happens with the cubic on a kinked curve.
- Isotonic regression is also adaptive: on flat or piecewise-constant regions it converges faster (close to log n/n).
Variants:
- L1 isotonic regression uses medians in place of means, for robustness.
- Multidimensional isotonic regression imposes a partial order.
- Smoothed isotonic fits add a spline step after isotonic regression to remove the steps.
- Monotone constraints are also available in gradient boosting (monotonic_cst).
Interview questions.
- Isotonic or Platt (sigmoid) calibration? Isotonic is more flexible but needs more data (roughly 1000 or more calibration points). Platt has two parameters and is better for small calibration sets.
- Why are isotonic fits step functions? Pooled blocks are constant, and between data points nothing pins the shape.
- 1. Isotonic MSE rate for a general monotone function?
- 2. Isotonic regression is the projection of y onto…
- 3. Platt scaling is preferred over isotonic calibration when…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Calibrating a saturating detector
History.
- Ayer, Brunk, Ewing, Reid and Silverman (1955) introduced PAVA for estimating monotone probabilities.
- Brunk (1955), van Eeden and Barlow et al. (1972, Statistical Inference under Order Restrictions) developed the theory.
- Groeneboom (1985) derived the cube-root asymptotics.
- Zadrozny and Elkan (2002) popularised isotonic calibration of classifiers.
- Niculescu-Mizil and Caruana (2005) compared it with Platt scaling.
Exercise 1. Fitting tanh(5(x − 0.4)) from 300 noisy points (σ = 0.2) gives a 31-step staircase with MSE 0.0023, against 0.0424 for a straight line. Random monotone perturbations never reduce the squared error, and the fitted mean equals the data mean.
Exercise 2: detector calibration. Setup: the response is min(2x, 1) + 0.1x, linear up to a sharp saturation knee at x = 0.5, with noise σ = 0.1. The table shows the MSE against the true curve over 60 calibration sets per size.
| n | Linear | Cubic polynomial | Isotonic |
|---|---|---|---|
| 25 | 0.0220 | 0.0035 | 0.0033 |
| 100 | 0.0202 | 0.0016 | 0.0015 |
| 400 | 0.0198 | 0.0014 | 0.00057 |
| 1600 | 0.0197 | 0.0013 | 0.00022 |
| log–log slope | −0.02 | −0.23 | −0.66 |
- Isotonic regression keeps improving at the theoretical n^(−2/3) rate (measured slope −0.66).
- The cubic stalls at its bias floor: it cannot bend sharply at the knee. By n = 1600 its error is 6 times the isotonic error.
- The straight line is hopeless at any n.
- At n = 25 the cubic and isotonic fits are about equal: with little data, isotonic’s coarse steps cost as much as the cubic’s bias.
Isotonic regression in AI, robotics and aerospace
- Sensor and detector calibration: monotone transfer curves with saturation or dead zones.
- Probability calibration: turning detector or classifier scores into reliable probabilities.
- Dose–response and degradation: radiation dose versus damage, cycles versus capacity fade.
- Ranking and monotone ML: monotone constraints in gradient boosting and lattice models.
References
- M. Ayer, H. D. Brunk, G. M. Ewing, W. T. Reid, E. Silverman (1955). “An empirical distribution function for sampling with incomplete information.” Annals of Mathematical Statistics 26(4).
- R. E. Barlow, D. J. Bartholomew, J. M. Bremner, H. D. Brunk (1972). Statistical Inference under Order Restrictions. Wiley.
- P. Groeneboom (1985). “Estimating a monotone density.” Proceedings of the Berkeley Conference in Honor of Neyman and Kiefer.
- B. Zadrozny, C. Elkan (2002). “Transforming classifier scores into accurate multiclass probability estimates.” KDD.
- A. Niculescu-Mizil, R. Caruana (2005). “Predicting good probabilities with supervised learning.” ICML.