Experimental learners: NGBoost, FT-Transformer, TabM and deep ensembles
Four Experimental learners that predict a distribution or average many networks. Watch the spread overfit, read what ensemble disagreement means, and decide when a deep model is worth its time.
What runs in CodeSplash
- NGBoost (natural gradient boosting) Experimental
- FT-Transformer Experimental
- TabM (parameter-efficient MLP ensemble) Experimental
- Deep ensemble Experimental
You will be able to
- Say what NGBoost, FT-Transformer, TabM and a deep ensemble each add
- Check a distributional model's held-out coverage before trusting its intervals
- Tell disagreement between networks (epistemic) from noise in the data (aleatoric)
Four Experimental learners
ReadThese learners live in the gallery's Experimental tier. Each trains in Python and R from the same random stream, so both engines give the same model.
| Learner | What it adds |
|---|---|
| NGBoost | A whole distribution per row, boosted with natural gradientsNatural gradientA gradient divided by the Fisher information, so each step moves the predicted distribution by a similar amount whatever its parameters. |
| FT-Transformer | Every feature becomes a tokenFeature tokenizerTurning each feature into a learned vector (b + x·W), so a Transformer can treat the columns of a table like the words of a sentence., and attention mixes them |
| TabM | Many MLPs sharing weights through BatchEnsembleBatchEnsembleAn ensemble whose members share every weight matrix and differ only by small per-member scaling vectors. adapters |
| Deep ensemble | Several networks trained apart, giving an interval that widens where they disagree |
The spread overfits first
PredictPredict first
NGBoost on ozone with depth-3 trees and leaves of a single row reaches an RMSE of 21.0. What share of held-out rows do its 90% intervals cover?
Reveal
Far below 90%: 0.333. Tiny leaves let each row's SD shrink towards its own residual. With shallower trees, leaves of 10 rows and a smaller learning rate, coverage is 0.892 at an RMSE of 19.9.
Reading the predicted distributions
ReadEach NGBoost run draws the Predicted distributions chart: the curves of five training rows, from low to high predicted mean. A narrow, tall curve is a confident prediction. The dashed line rises from each row's actual value to the density the model gave it, which is what the log score rewards.
NGBoost differs from Distributional boosting in its line search: each round tries larger and smaller steps and keeps one that improves the training score. It also offers other distributions (Laplace, log-normal, exponential, Poisson), CRPS and class probabilities.
Averaging networks
ExploreAveraging many flexible models cancels part of their variance. Raise Trees in the bag and watch Variance, the bag fall while Variance, one tree stays where it was.
DExplorable · Averaging models, and going past the interpolation point
When can adding more model lower the error instead of raising it?
Classical advice says more model means more variance. Going much further here (25 trees instead of one, or six times as many features as rows) will make predictions on new data…
Experiment
Commit your prediction above to see the result
Make your prediction to see the result.
TabM gets this inside one network. On Pima its members average to an AUC of 0.861, against 0.837 for one torch MLP and 0.856 for the FT-Transformer.
Two kinds of uncertainty
ReadA deep ensemble's members each predict a mean and a variance. Their own variances are the noise in the data, the aleatoricAleatoric uncertaintyUncertainty from noise in the outcome itself, which no amount of data removes. part. How far their means disagree is the epistemicEpistemic uncertaintyUncertainty from not knowing the right model, which more data can shrink; seen as disagreement between ensemble members. part, which more data can shrink.
On ozone, disagreement makes up 0.0763 of the predictive variance on the training rows, and the 90% intervals cover 0.871 of held-out rows. The Ensemble spread chart shows the members around their consensus.
When is a deep model worth it?
ReflectOn a few hundred rows, these networks land close to boosted trees and a small MLP, and they take longer on a CPU. They pay off on large tables with many interacting features, or when you need a calibrated spread.
Think of a table you work with. How many rows does it have, and what would you gain from an interval per row?
Check your understanding
CheckpointCheck yourself
An NGBoost model has a good RMSE, but its 90% intervals cover 40% of held-out rows. What do you try first?
Show the answer
Answer: a
The scale parameter overfits faster than the mean. Coverage on held-out rows is the check, and it is in every run's metrics.
Check yourself
Where would you expect a deep ensemble's members to disagree most?
Show the answer
Answer: b
Disagreement is epistemic uncertainty: it grows away from the data and shrinks with more of it. Noise in the outcome is the aleatoric part, which each member estimates itself.
Check yourself
Why is TabM's member spread not a predictive interval?
Show the answer
Answer: a
Read TabM's spread as model disagreement. For an interval, use a deep ensemble, NGBoost or the conformal wrappers in Uncertainty.
Train them
In the appIn the Learners step, select NGBoost (natural gradient boosting) next to Distributional boosting and train both. Each run's Overview lists its 90% coverage among the scores and draws its charts: Predicted distributions for NGBoost, Training curves for the deep learners, with a ring at the epoch early stopping kept.
import numpy as np
import pandas as pd
from ngboost import NGBRegressor
from sklearn.model_selection import KFold
from sklearn.tree import DecisionTreeRegressor
df = pd.read_csv("airquality.csv").dropna()
X = df[["Solar.R", "Wind", "Temp", "Month"]].to_numpy()
y = df["Ozone"].to_numpy()
hit = []
for tr, va in KFold(3, shuffle=True, random_state=1).split(X):
base = DecisionTreeRegressor(max_depth=2, min_samples_leaf=10)
m = NGBRegressor(Base=base, n_estimators=40, learning_rate=0.05, verbose=False).fit(X[tr], y[tr])
d = m.pred_dist(X[va])
hit.append(np.abs(y[va] - d.params["loc"]) <= 1.645 * d.params["scale"])
print("90% interval coverage", round(np.concatenate(hit).mean(), 3))library(codesplashr) # the app's helper package: the same NGBoost as the Python twin
df <- na.omit(airquality)
X <- as.matrix(df[, c("Solar.R", "Wind", "Temp", "Month")])
y <- df$Ozone
set.seed(1)
fold <- sample(rep(1:3, length.out = length(y)))
hit <- unlist(lapply(1:3, function(k) {
m <- cs_ml_ngboost_fit(X[fold != k, ], y[fold != k], NULL, "normal", n_estimators = 40L,
learning_rate = 0.05, max_depth = 2L, min_samples_leaf = 10L)
p <- cs_ml_ngboost_predict(m, X[fold == k, ])
abs(y[fold == k] - p$mean) <= qnorm(0.95) * p$sd
}))
round(mean(hit), 3)Recap
Recap- NGBoost predicts a distribution per row; check held-out coverage, because the spread overfits before the mean does.
- FT-Transformer and TabM are strong deep models for tables, but slow on a CPU and rarely better on small data.
- A deep ensemble's spread combines noise in the data with disagreement between networks.
Concepts in this lesson