Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Predict how sure you are, not just what you expect
A remaining-life prediction of “120 hours” is far more useful as “120 hours, give or take 10” or “120, give or take 60”. NGBoost predicts a whole distribution for every input, such as a Normal with mean μ(x) and standard deviation σ(x). It boosts two sets of trees side by side, one for the mean and one for the spread, so the uncertainty can grow in regimes where the data are noisy and shrink where they are consistent.
Decisions under uncertainty, such as maintenance scheduling, safety margins, launch weather and battery state of health, need calibrated uncertainty, not point estimates. NGBoost gives input-dependent predictive intervals with the convenience of tree boosting on tabular data, and any scoring rule (log-likelihood, CRPS) and distribution family (Normal, LogNormal, Poisson, Exponential for survival).
- 1. NGBoost predicts…
- 2. For a Normal it boosts trees for…
- 3. In the demo the interval should be…
Level 1: Beginner
★★☆☆☆ Basic⏱ 30 minSecondary-school mathematics: arithmetic and elementary algebra.Gradients for a Normal by hand
Score: the negative log-likelihood NLL = log σ + (y − μ)²/(2σ²) + ½ log 2π. Use the parameters (μ, s = log σ).
Ordinary gradient at y = 2, μ = 1, σ = 1 (s = 0):
- ∂NLL/∂μ = (μ − y)/σ² = −1;
- ∂NLL/∂s = 1 − (y − μ)²/σ² = 1 − 1 = 0. The spread is already right for this residual.
Fisher information of a Normal in (μ, s): I = diag(1/σ², 2). With σ = 0.5 it is diag(4, 2).
Natural gradient = I⁻¹ × ordinary gradient = (σ²·(μ − y)/σ², (1 − (y − μ)²/σ²)/2) = (μ − y, (1 − (y − μ)²/σ²)/2).
- The mean’s update no longer divides by σ², so points in noisy regions do not get tiny updates while points in quiet regions get huge ones.
- At y = 2, μ = 1, σ = 1 the natural gradient is (−1, 0), the same as the ordinary one because σ = 1.
Interval. If the model predicts μ = 3 and σ = 0.5, a 90% interval is 3 ± 1.645·0.5 = (2.18, 3.82).
The steps in plain English:
- Choose a distribution family and a proper scoring rule. Start every point at the marginal fit (mean and log standard deviation of y).
- Each round, compute the natural gradient of the score for every point and parameter.
- Fit one regression tree per parameter to the negative natural gradients. Find a step size by line search, then shrink it (ν ≈ 0.01–0.1).
- Stop on validation NLL. Predict the distribution, and derive intervals and quantiles from it.
- 1. ∂NLL/∂μ for y = 3, μ = 1, σ = 2?
- 2. Fisher information for log σ in a Normal?
- 3. 90% interval for μ = 3, σ = 0.5?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.The algorithm and its ingredients
Proper scoring rules. A score S(P, y) is proper if the true distribution minimises its expectation. Strictly proper scores (log score, CRPS) reward both calibration and sharpness, unlike squared error, which only rewards the mean.
Natural gradient (Amari, 1998). The ordinary gradient depends on the parameterisation: (μ, σ), (μ, log σ) and (μ, σ²) give different directions. The natural gradient ∇̃ = I(θ)⁻¹∇ is the steepest-descent direction measured in KL divergence between distributions, so it is invariant to reparameterisation. For the log score, I is the Fisher information. For CRPS it is the corresponding Riemannian metric.
NGBoost loop.
- Initialise θ⁽⁰⁾ by maximum likelihood on all of y.
- Each round, compute gᵢ = I(θᵢ)⁻¹∇_θ S(θᵢ, yᵢ).
- Fit one tree f_k per parameter k to −g_ik.
- Find a scaling ρ by line search, then update θᵢ ← θᵢ + ν·ρ·f(xᵢ).
Comparisons.
| Method | output | heteroscedastic? | calibration |
|---|---|---|---|
| L2 boosting + global σ | mean, one σ | no | wrong where noise differs |
| Quantile boosting | separate quantile models | yes | no joint distribution; quantiles may cross |
| NGBoost | full parametric distribution | yes | good if the family fits |
| Gaussian processes | full distribution | with special kernels | good, but scales poorly |
from ngboost import NGBRegressor
from ngboost.distns import Normal
ngb = NGBRegressor(Dist=Normal, n_estimators=500, learning_rate=0.05).fit(X_tr, y_tr, X_val=X_va, Y_val=y_va,
early_stopping_rounds=50)
dist = ngb.pred_dist(X_te); lo, hi = dist.ppf(0.05), dist.ppf(0.95)- 1. A proper scoring rule is minimised in expectation by…
- 2. The natural gradient is invariant to…
- 3. A drawback of separate quantile models is…
Level 3: Advanced
★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.Theory
Why natural gradients. With ordinary gradients in (μ, log σ), the mean’s gradient (μ − y)/σ² is huge where σ is small and tiny where σ is large, so trees fitted jointly are dominated by low-noise regions. The natural gradient multiplies by σ², restoring a balanced update. This matters for stability and for the joint fitting of μ and σ. It is not a guarantee of faster training-loss decrease: exercise 1 found that ordinary gradients with line search lowered the training NLL faster but overfit sooner (test NLL 1.41 against 1.30 after 200 rounds).
Calibration. Minimising a strictly proper score with enough data yields calibrated predictive distributions if the family is right. If the true noise is skewed or heavy-tailed, a Normal family gives miscalibrated tails. Check probability-integral-transform (PIT) histograms and coverage, and consider LogNormal, Laplace or Student-t families.
Overfitting in σ. Over-boosting drives σ(x) too small on training points (they look “certain”), producing over-confident intervals. Exercise 1: coverage of 87% at 100 rounds fell toward 82% by 200 rounds. Early stopping on validation NLL is essential.
Interview questions.
- How would you get prediction intervals from a boosted model? Use quantile boosting (two models), NGBoost (a distribution), conformal prediction on top of any model (distribution-free coverage), or bootstrapped ensembles.
- Why is a global σ inadequate? With heteroscedastic noise, a single σ is too wide where noise is low and too narrow where it is high. Exercise 2: 100% coverage in the quiet region against 79% in the noisy one.
- 1. Ordinary gradients for μ are dominated by points with…
- 2. Over-boosting NGBoost tends to make intervals…
- 3. To check calibration of predictive distributions, use…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Intervals on heteroscedastic data
History.
- Amari (1998) introduced the natural gradient.
- Gneiting and Raftery (2007) set out the theory of proper scoring rules.
- GAMLSS (Rigby and Stasinopoulos, 2005) introduced distributional regression with additive models.
- Duan, Avati et al. (2020, ICML) published NGBoost.
- Related methods include distributional gradient boosting (März), PGBM (2021) and CatBoost’s uncertainty modes.
Exercise 1.
- After 100 rounds, training NLL fell from 1.612 to 1.116.
- The predicted σ correlated 0.94 with the true σ, and 90% intervals covered 87.2% of test points.
- After 200 rounds, test NLL was 1.303 with natural gradients against 1.409 with ordinary gradients.
Exercise 2. Setup: σ = 0.2 for x₀ below 0 and 1.0 above, n = 800, early stopping on validation, 2 repetitions. The true 90% interval widths are 0.66 and 3.29.
| Method | test NLL | 90% coverage | coverage in low-noise half | coverage in high-noise half | width (low, high) |
|---|---|---|---|---|---|
| NGBoost | 0.805 | 0.863 | 0.892 | 0.837 | (0.86, 2.90) |
| L2 boosting + global σ | 1.140 | 0.891 | 1.000 | 0.786 | (2.52, 2.52) |
| quantile boosting (τ = 0.05, 0.95) | (none) | 0.818 | 0.790 | 0.844 | (0.69, 2.94) |
- A per-point σ cut the test NLL by 0.34. The global-σ model’s overall coverage (0.89) looks fine but hides 100% coverage where noise is low and 79% where it is high.
- NGBoost and quantile boosting both adapted their widths by a factor of 3–4.
- Both were somewhat over-confident (82–86% instead of 90%). That is common after fitting on 800 points. Conformal calibration on held-out data is the standard fix.
Probabilistic boosting in AI, robotics and aerospace
- Remaining-useful-life prediction with input-dependent uncertainty for maintenance planning.
- Battery state of health and range estimation with confidence bands.
- Weather-dependent launch and landing decisions using predictive distributions.
- Survival analysis of component lifetimes (Exponential or Weibull families).
References
- T. Duan, A. Avati, D. Y. Ding, K. K. Thai, S. Basu, A. Ng, A. Schuler (2020). “NGBoost: natural gradient boosting for probabilistic prediction.” ICML.
- S. Amari (1998). “Natural gradient works efficiently in learning.” Neural Computation 10(2).
- T. Gneiting, A. E. Raftery (2007). “Strictly proper scoring rules, prediction, and estimation.” JASA 102.
- R. A. Rigby, D. M. Stasinopoulos (2005). “Generalized additive models for location, scale and shape.” Applied Statistics 54(3).
- A. N. Angelopoulos, S. Bates (2023). “Conformal prediction: a gentle introduction.” Foundations and Trends in Machine Learning 16(4).