From a classifier to Fisher-preserving bins

A signal fraction is to be estimated, the component densities are unknown, and labelled simulations are available. A calibrated classifier supplies the score and ScoreQuant bins it. How much of the information the bins report is real?

1. A mixture without a likelihood​

Each event comes from signal or background, and the quantity to measure is the signal fraction θ\theta:

p(x∣θ)=θ ϕsig(x)+(1−θ) ϕbkg(x).p(x\mid\theta) = \theta\,\phi_{\rm sig}(x) + (1-\theta)\,\phi_{\rm bkg}(x).

In a realistic analysis neither component density can be evaluated: xx may be high-dimensional, and the components exist only as simulation. What is available is labelled simulated events, which is exactly what a classifier is trained on.

Here the components are two normal densities, ϕsig=N(1, 0.52)\phi_{\rm sig}=\mathcal N(1,\,0.5^2) and ϕbkg=N(0, 1.52)\phi_{\rm bkg}=\mathcal N(0,\,1.5^2), and the reference signal fraction θ0\theta_0 is 0.30. The fit pretends not to know them. Afterwards the exact densities give the exact score, and that oracle answers a question a real analysis cannot: when the bins report that they keep almost all the information, how much of that is true?

From a classifier to Fisher-preserving binsTwo lanes. The upper lane runs left to right through five steps: labelled simulations, a classifier, the conversion of its posteriors into a density ratio and then a score, ScoreQuant compressing that score into K hard bins, and finally the fit of the signal fraction. The lower lane, marked as available only in this synthetic model, runs through the exact densities, the exact score, and the retention those same fitted bins achieve against it. A dashed arrow carries the fitted bins from the upper lane down into the lower one.ANALYSIS WORKFLOWINPUTLabelledsimulationsLEARNClassifiercalibratedposteriorsCONVERTRatio toscoreCOMPRESSScoreQuantK hard bins inthe estimated scoreINFERFit θfrom the bincounts aloner̂(x) → ŝ(x; θ₀)posterior oddsover prior oddsclassifier quality enters hereCONTROLLED ORACLE CHECK · SYNTHETIC MODEL ONLYONLY IN THIS TOY MODELExact densitiesREFERENCEExact scores(x; θ₀)EVALUATEAchieved retentionin the exact scorethe same fitted binsTop: the workflow a real analysis runs. Bottom: the oracle check, available here only because the synthetic densities are known.
The two lanes of this page. Top: the workflow a real analysis can run, from labelled simulations through a calibrated classifier and a density ratio to a score, which ScoreQuant compresses into hard bins. Bottom: the check only a synthetic model allows, in which the exact densities give the exact score and the same bins are evaluated against it.

2. From classifier probabilities to a score​

The score of a mixture depends on the data only through density ratios, and a classifier estimates density ratios.

A classifier trained on components mixed in proportions πk\pi_k estimates the posterior ηk(x)=πk ϕk(x)/ptrain(x)\eta_k(x)=\pi_k\,\phi_k(x)/p_{\rm train}(x), where ptrain=∑jπjϕjp_{\rm train}=\sum_j\pi_j\phi_j is the training mixture. Dividing by the training proportion removes the prior:

rk(x)=ηk(x)πk=ϕk(x)ptrain(x).r_k(x) = \frac{\eta_k(x)}{\pi_k} = \frac{\phi_k(x)}{p_{\rm train}(x)}.

The proportions to divide by are those of the training sample, not the fractions of the model. A classifier trained on balanced classes has πk=1/2\pi_k=1/2 whatever the signal fraction of the data.

The score is the derivative of the log density at θ0\theta_0, and it can be written in ratios alone:

s(x)=ϕsig(x)−ϕbkg(x)θ0 ϕsig(x)+(1−θ0) ϕbkg(x)=rsig(x)−rbkg(x)θ0 rsig(x)+(1−θ0) rbkg(x).s(x) = \frac{\phi_{\rm sig}(x)-\phi_{\rm bkg}(x)} {\theta_0\,\phi_{\rm sig}(x)+(1-\theta_0)\,\phi_{\rm bkg}(x)} = \frac{r_{\rm sig}(x)-r_{\rm bkg}(x)} {\theta_0\,r_{\rm sig}(x)+(1-\theta_0)\,r_{\rm bkg}(x)}.

The reason is simple: numerator and denominator are both linear in the densities, so a factor c(x)c(x) that multiplies every ratio of an event cancels. That freedom is the gauge. Ratios to the training mixture, as above, ratios to the background, with rbkg=1r_{\rm bkg}=1, and ratios to the reference density all give the same score, and no component density is ever needed on its own. The same cancellation holds with more components, in a normalized mixture and in a rate model whose coefficients float freely.

The gauge is free only if it is shared. Every ratio column of an event must carry the same factor c(x)c(x): a signal ratio from a classifier, relative to the training mixture, placed beside an absolute background density from Monte Carlo gives a wrong score. ScoreQuant refuses such a mix when the providers declare their gauges, but the numbers alone cannot reveal it (user guide (opens in a new tab)). Nor can it check that the posteriors are calibrated, or that πk\pi_k are the true training proportions.

DensityRatioScore.from_classifier performs both steps, the prior correction and the ratio-to-score map. It records the provider as an estimated ratio, so every result built on it is labelled supplied_score_surrogate, never exact_fisher (API guide (opens in a new tab)).

3. The experiment​

The classifier is a logistic regression on xx and x2x^2, trained on balanced samples of 15, 60 and 300 events per component. The exact log-ratio of two normal densities is quadratic in xx, so the model can represent it; only the amount of training data changes. Everything downstream stays fixed: the events the bins are fitted on, a held-out sample from the same reference mixture, and the budget of 4 bins. The data and the classifier come from the study code, examples/door3_classifier.py; the conversion is shown in full.

import numpy as np

import scorequant as sq
from examples.door3_classifier import (
draw_reference_mixture,
draw_training_mixture,
exact_provider,
make_features,
train_classifier,
)

train_observations = draw_reference_mixture(2026, 400)
test_observations = draw_reference_mixture(999, 600)
model = train_classifier(seed=101, n_per_class=15)


def posteriors(observations):
return model.predict_proba(make_features(np.asarray(observations)[:, 0]))


estimated = sq.ratios.DensityRatioScore.from_classifier(
posteriors,
[0.5, 0.5], # training proportions: balanced classes
sq.ratios.MixtureParameterization([0.3, 0.7]), # reference fractions, background last
)

quantizer = sq.fit_quantizer(
sq.ObservationSample(train_observations),
provider=estimated,
n_bins=4,
criterion=sq.DOptimality(),
config=sq.DExchangeConfig(seed=7),
)
assert quantizer.information_kind == "supplied_score_surrogate"

From the provider onward, fit_quantizer treats the estimated score s^\hat s like any other score. The larger training sizes change only the model line.

4. Reported versus achieved retention​

The retention a fit reports is a ratio: the information the bins keep about a score, over that score's unbinned information. Both are computed from s^\hat s. The reason the report cannot see a bad classifier is simple: the bins are graded against the very score they were fitted to.

Here the exact score is also known, so the same bins can be graded twice. The held-out events are assigned with s^\hat s, as a real analysis would assign them, and the resulting labels are evaluated once against s^\hat s and once against the exact score ss:

estimated_scores = estimated.score(test_observations)
reported = quantizer.evaluate_scores(estimated_scores).geometric_mean_retention

labels = quantizer.predict_scores(estimated_scores)
achieved = sq.information_report(
exact_provider().score(test_observations), labels, n_bins=quantizer.n_bins
).geometric_mean_retention
Paired bars at three classifier training sizes: the D-efficiency the estimated score reports about itself, beside the D-efficiency its labels achieve against the exact score. The reported bars are nearly equal; the achieved bar is clearly lower at the smallest size and catches up as the training size grows.
Reported retention (left of each pair), measured against the estimated score, and achieved retention (right), measured against the exact score with the same labels. They converge only as the classifier does.

The reported retention barely moves with the training size. With 15 events per component the bins report 0.9658 and achieve 0.8847. With 300 the two agree to within 0.0035: the bins did not change their behaviour, the score they were given got better.

ScoreQuant measures the information lost by binning. Information lost earlier, when the score was estimated, is invisible to it, which is what the surrogate label means.

5. A check without the exact score​

A real analysis has no exact score, but it can test one consequence of the construction. Each ratio to the training mixture averages to one under that mixture, because Etrain[rk]=∫ϕk dx=1\mathbb E_{\rm train}[r_k]=\int\phi_k\,dx=1. ratio_closure_report measures the largest deviation on a sample:

closure_observations = draw_training_mixture(4242, 50_000)
closure = sq.ratios.ratio_closure_report(
estimated.ratio(closure_observations), np.ones(len(closure_observations))
)

The residual falls from 0.0420 at 15 events per component to 0.0032 at 300. A large residual exposes a bad ratio; a small one is necessary but not sufficient, since closure tests the normalization and not the shape (glossary (opens in a new tab)).

Here the gauge does matter. A ratio to the training mixture averages to one under the training mixture and under nothing else, so the sample must be drawn from it: balanced here, not the reference mixture of the data. On the reference mixture even the exact ratio leaves a residual of 0.1800, larger than the worst classifier's.

6. What the result means​

A classifier makes the score computable without a likelihood. Its calibrated posteriors, divided by the training proportions, are density ratios in a gauge the score does not see, and ScoreQuant bins that score as well as it bins any other. What it reports, though, is how much of the estimated score survives the binning, not how much of the information in the data. A better classifier closes that gap; the binning cannot, and closure on the training mixture is the check a real analysis has.

The binning itself was the easy part here. With one score coordinate, equal-width or quantile bins of the same estimated score come close to the fitted partition, and at the largest training size equal-width bins edge slightly ahead. The choice of cells matters when several score coordinates must share a few bins, as in the Higgs search and the cell populations, both of which build their scores as described above.