harbor run -t bespokelabs/label-efficient-risk-estimatorharbor download bespokelabs/label-efficient-risk-estimatorA classifier f assigns a probability distribution over C classes to each of N = 2000
unlabelled pool examples. Its risk on that pool is
$$ R = \frac{1}{N} \sum_i -\log \text{target_probs}[i, y_i] $$
where y_i is the true (unknown) class of example i. You may buy at most M of these
labels, one at a time, choosing each next example after seeing every label you've already
bought. Your job is to estimate R.
You're also given, for the same pool and row order, the predictive distributions of a second,
cheaper classifier over the same C classes. You aren't told how good it is, and that varies
from pool to pool.
Write /app/output/estimator.py, defining a class named exactly Estimator:
class Estimator:
def __init__(self, pool: dict, budget: int, rng: numpy.random.Generator) -> None: ...
def next_index(self) -> int: ...
def observe(self, index: int, label: int) -> None: ...
def estimate(self) -> float: ...
pool has exactly these keys:
| key | type |
|---|---|
target_probs |
C-contiguous float64 ndarray, shape (n_pool, n_classes), rows sum to 1 |
surrogate_probs |
C-contiguous float64 ndarray, shape (n_pool, n_classes), rows sum to 1 |
n_pool |
int, always 2000 |
n_classes |
int, always 2 |
Requirements:
/app/output/, as long as they're importable from
estimator.py.numpy, scipy. Nothing else is installed, and there's no network access./app/output
cross over, so your solution must be fully self-contained there.The harness, not your code, drives the loop: it calls next_index() exactly budget times,
and right after each call it calls observe(index, label) with the true class of the row you
named. Naming a row you've already bought is legal and still uses up one unit of budget. After
the last observe, estimate() is called once.
M, where M is one of
{50, 100, 200, 400}.Estimator and records the squared error$$ (\text{estimate}() - R)^2 $$
against the exact pool risk R, which it knows and you don't.
$$ \text{score} = \frac{\text{median over the 4000 seeds of your squared error}}{\text{median over the SAME 4000 seeds of the squared error of the reference}} $$
M rows uniformly at random, without replacement, from the same
rng seed you're given, and returns the plain mean of their -log target_probs[i, y_i].The held-out pools span several source corpora, classifier pairs, and calibration regimes, including pools where the target classifier is accurate and well-calibrated and pools where it's badly miscalibrated. No single fixed design wins on all of them.
/app/data/dev/ holds twelve labelled pools you can use however you like. Each
/app/data/dev/<pool_id>/ contains:
target_probs.npy - float64 (2000, n_classes)surrogate_probs.npy - float64 (2000, n_classes)labels.npy - int64 (2000,), values in [0, n_classes)meta.json - {"pool_id", "n_pool", "n_classes"}The held-out pools come from disjoint shards of the same corpora and are never shipped to you.
/app/output. It's re-executed from source for every seed, so no state survives from one
seed to the next: do per-pool precomputation in __init__, not at module scope. The pool row
order is re-randomised on every seed, so row indices mean nothing across seeds./app/output must hold at most 2000 files totalling at most 256 MB.next_index() outside [0, n_pool), a non-finite estimate(), or exceeding the per-seed
clock. Exceeding the per-cell clock, or trying to obtain more than budget labels in a seed,
scores the worst case for the whole cell./app/output/estimator.py scores zero.