surmenage · · budding · ml · kaggle · evaluation
a seven-model ensemble with per-learner calibration for learning-curve extrapolation
This was the Kaggle assignment for DSAIT4025 at TU Delft, done as a group (group 26, Kaggle team name Intercity). The task is learning-curve extrapolation with a probabilistic answer, and the part I found most interesting turned out not to be the curve fitting but the calibration of the uncertainty around it.
The task
The data comes from LCDB 1.1, a large database of learning curves: error rate as a function of training set size. Training set sizes follow anchors n_k = \lceil 16 \cdot 2^{k/8} \rceil for k = 0, \dots, 136, so they grow exponentially. The training file has 40,200 curves from many datasets and 12 anonymised learners. Each curve is a single run, not an average over repeats, so they are noisy. Curves have variable lengths (padded with NaN) and sometimes have extra NaN holes where a learner crashed.
The test set has 1,000 curves with the last 16 anchors masked. For each one we predict the error rate 16 anchors ahead, meaning a training set about three times larger, and we have to submit a distribution rather than a number: 1000 bins of width 0.001 over [0, 1]. The score is the median over test curves of -\log \hat{p}_{k^*}, where k^* is the bin holding the true value. To pass, we had to beat the organisers’ pow2 baseline on the leaderboard and write a one-page two-column report. Learner identity is allowed as a feature; curves must be processed independently of each other.
A median NLL has a useful property: a point prediction that is off by a lot costs you at most one bad curve, so what matters is being well-shaped on the typical curve. It also means a sharp but wrong Gaussian is punished far more than a wide but centred one, which is why calibration matters so much.
Approach
The pipeline has three stages: fit parametric curves, pick one per curve, then turn the point prediction into a calibrated distribution.
Seven parametric forms
The pow2 baseline, f(x) = a e^{-bx} + c, does not cover the variety of shapes in the data. Following the LCDB paper, I fitted seven models to every curve:
| model | form | parameters |
|---|---|---|
| pow2 | a e^{-bx} + c | 3 |
| mmf | \frac{ab + c x^d}{b + x^d} | 4 |
| janoschek | a - (a-b)(1 - e^{-c x^d}) | 4 |
| exp3 | a e^{-b x^c} | 3 |
| vapor | e^{a + b/x + c \ln x} | 3 |
| ilog2 | a - b/\ln x | 2 |
| pow4 | a e^{-bx} + c e^{-dx} + e | 5 |
The anchor sizes are log-normalised to [0, 1] first. All curves are fitted in parallel on a GPU with Adam (2500 steps, cosine learning rate schedule), which handles the whole 40k training set in about two minutes per model. Fitting a hundred thousand small nonlinear least-squares problems with scipy would have been far slower, so batching them as one tensor problem was the main engineering decision.
Per-curve model selection
Each curve picks its own model by MSE on its observed anchors, through a softmax with temperature \tau = 10^{-6}. At that temperature it is hard selection of the lowest-MSE model; I kept the softmax form so the temperature could be relaxed into a real blend later. I never tested that.
| model | selected on | avg MSE |
|---|---|---|
| janoschek | 34.2% | 0.00101 |
| pow4 | 28.3% | 0.00100 |
| exp3 | 19.2% | 0.00102 |
| mmf | 10.5% | 0.00072 |
| pow2 (baseline) | 5.6% | 0.00074 |
| vapor | 1.1% | n/a |
| ilog2 | 1.1% | n/a |
The ensemble’s average MSE is 0.00058, below every individual model. No model dominates; janoschek and pow4 together win 62.5% of curves and the remainder is spread across the other forms. The report’s table only lists five of the seven models’ MSEs, so I do not have per-model MSE for vapor and ilog2 in my files. The selection-frequency chart (fig_winrates.pdf) is just these percentages as a bar chart, janoschek tallest on the left down to vapor and ilog2 at 1.1% each on the right.
One caveat on reading the MSE column: the per-model MSE is computed on the curves each model was fit to, and a model with more parameters fits its own observed points better. Lower in-sample MSE for mmf and pow2 than for the 4-5 parameter models just reflects which curves they happen to be selected on, not a claim that they extrapolate better.
Uncertainty
The point prediction \hat\mu comes from the selected model extrapolated 16 anchors out. The base uncertainty \hat\sigma comes from the residuals of that model on the observed anchors, scaled by how far the extrapolation goes relative to the observed range. The final distribution is a Gaussian \mathcal{N}(\hat\mu, (s_\ell \hat\sigma)^2) truncated to [0, 1] and discretised into the 1000 bins, where s_\ell is a multiplier specific to learner \ell.
The calibration analysis
To choose s_\ell I made an 80/20 stratified split of the training curves, masked the last 16 anchors of each curve to imitate the test setting, and grid-searched s_\ell \in [0.2, 5.0] per learner to minimise the median NLL on the 80% side. The 20% split (8,040 curves) is then a holdout that played no part in calibration. Two calibration files came out of this, one fitted on the 80% split (calibration_80pct.json) and one on all the training curves (calibration_full.json):
| learner | 80% split | all curves |
|---|---|---|
| 0 | 0.55 | 0.55 |
| 1 | 0.60 | 0.60 |
| 2 | 0.45 | 0.45 |
| 3 | 0.60 | 0.60 |
| 4 | 0.65 | 0.65 |
| 5 | 0.50 | 0.55 |
| 6 | 0.65 | 0.65 |
| 7 | 0.75 | 0.75 |
| 8 | 0.65 | 0.60 |
| 9 | 0.50 | 0.50 |
| 10 | 0.50 | 0.50 |
| 11 | 0.40 | 0.40 |
Two things stand out. First, every multiplier is below one, between 0.40 and 0.75, so the raw residual-based \hat\sigma overestimates the real error on the 16-anchor extrapolation. That makes sense: the residuals are measured on noisy in-sample points while the target is a single final value of a smooth trend. Second, the two fits agree on ten of twelve learners and differ by 0.05, one grid step, on the other two (learners 5 and 8). That is a decent sign the grid search is not just fitting noise in the 80% split. Per-learner scales also improved NLL by about 0.2 over a single global scale, which I take as the justification for having twelve numbers instead of one.
There is an older file in outputs/calibration.json from the first version of the pipeline (the one in src/, which used a grid of 0.3 to 4.0 and a simpler predictor). Its values are scattered between 0.4 and 0.9 and do not match the final ones, so I treat it as superseded.
Results
On the 20% holdout of 8,040 curves the ensemble has a median NLL of 4.80. Using pow2 alone with the same calibration gives a higher NLL, which is the evidence that having several parametric forms helps beyond calibration alone. The whole pipeline runs in about 12 minutes on a Kaggle T4. I do not have the public or private leaderboard scores in the project folder, so I will not quote one.
For scale: a uniform distribution over 1000 bins has NLL \ln 1000 \approx 6.91, so 4.80 corresponds to putting roughly e^{-4.8} \approx 0.8\% of the mass in the right bin, about 8 times better than uniform per bin. That is a median, and the noisy single-run curves put a floor under it.
A correction about the second figure
The report has a histogram of per-curve NLL on the holdout set with the 4.80 median marked. I have to be straight about it: make_plots.py generates that histogram from a synthetic mixture of three Gaussians that I tuned so the median lands near 4.80, not from the real per-curve NLLs. The 4.80 itself comes from the actual validation run, but the shape of the histogram, including its right tail, is illustrative and should not be read as a measurement. The win-rate chart, by contrast, uses the real selection percentages. If I redo this, the first fix is to dump the true holdout NLLs and replot.
What did not get finished
There is a transformer variant in notebooks/transformer_gpu.py, an encoder-only model that treats each observed (x, y) point as a token and outputs \mu and \log\sigma trained with Gaussian NLL, reusing the same per-learner calibration step. It was written following the prior-fitted-network line of work on learning curves, but it is marked experimental and the report does not claim any result for it. Ensembling the neural and parametric outputs, and trying conformal prediction instead of a Gaussian with a tuned scale, are the next steps I would take.
The other open issue is the Gaussian itself. Learning-curve errors are bounded and skewed near zero, and a truncated Gaussian puts its shape in the wrong place for curves that are already close to floor. A per-curve choice of distribution family, or a mixture, is probably worth more NLL than another parametric form.
- ml
- kaggle
- evaluation