Non-random labelling¶
PPI assumes that the labelled cases are a uniform random sample. Two situations break this assumption.
Known selection probabilities¶
Labels are often selected on purpose: rare subgroups are oversampled, or the cases where the model is least certain are sent to experts (active labelling). If every case \(i\) is selected independently with a known probability \(\pi_i\), the inverse probability weighted estimator is unbiased:
pi = fl.inclusion_probabilities(scores, budget=500, floor=0.01)
labeled = fl.poisson_sample(pi, seed=0)
# send the selected cases for labelling, then
result = fl.ipw_ppi_mean(y_all, preds_all, labeled, pi)
y_all contains the outcomes of all cases; entries of unlabelled cases are
ignored and may be NaN.
Choosing the probabilities
The variance is smallest when \(\pi_i\) is proportional to the expected
absolute error of the prediction. For a binary outcome with predicted
probability \(p_i\), a good score is \(\sqrt{p_i(1-p_i)}\). Keep a small
floor so that every case can be selected.
Unknown selection: sensitivity analysis¶
If the selection mechanism is unknown, for example because some cases were
skipped by the reviewers, no estimator is unbiased without assumptions.
selection_sensitivity reports how far the estimate could move if the odds
of being labelled differed by up to a factor \(\Gamma\) from the assumption:
for r in fl.selection_sensitivity(y, preds_labeled, preds_unlabeled, gamma=[1, 1.25, 1.5, 2]):
print(r.gamma, r.lower, r.upper, r.ci_lower, r.ci_upper)
tipping_point returns the smallest \(\Gamma\) at which the interval
includes a value of interest:
fl.tipping_point(y, preds_labeled, preds_unlabeled, null=0.15)
Report the tipping point together with the main result. A value close to 1 means that a weak selection effect could overturn the conclusion.