Sam Babichenko

Reading notes / Missing and selective labels

Learning from positive and unlabeled data

Elkan and Noto, 2008; Kiryo et al., 2017

Context. Many data sets list positives and nothing else: a curated database names the proteins that belong in it, and everything else mixes true negatives with positives nobody has labeled yet. Elkan and Noto show that if a positive's chance of being labeled does not depend on xx, a classifier trained to separate labeled from unlabeled is the right classifier up to one constant, the label frequency cc. Later unbiased risk estimators (du Plessis et al., 2014 and 2015) take the class prior πp\pi_p and minimize any loss directly; with deep networks their training risk goes below zero, which no true risk can do, and the test risk climbs, so Kiryo et al. clip the offending term at zero. Under random labeling, PU learning reduces to one nuisance number, cc or equivalently the prior, a correction of the same kind as moving a classifier to a new base rate. And whenever an unbiased estimator subtracts one empirical term from another, a flexible model will fit the sampling error in the difference, and imposing the sign the population term must have is a simple correction.

Setting. Triples (x,y,s)(x,y,s), with ss the indicator that a point was labeled, are drawn i.i.d. and only (x,s)(x,s) is recorded (the single-training-set scenario). Only positives are labeled, and labeling is selected completely at random (SCAR):p(s=1∣x,y=1)=p(s=1∣y=1)=c,p(s=1\mid x,y=1)=p(s=1\mid y=1)=c,equivalently s⊥x∣ys\perp x\mid y. The nontraditional classifier g(x)≈p(s=1∣x)g(x)\approx p(s=1\mid x) is any probabilistic learner fit to labeled versus unlabeled; the target is f(x)=p(y=1∣x)f(x)=p(y=1\mid x). In the case-control scenario, used by Kiryo et al. with πp\pi_p given, labeled positives and an unlabeled background sample are drawn separately, so the labeled share is a design choice and the prevalence is not identified.

Step 1

SCAR makes labeling a constant thinning of the positives, so g/cg/c is the posterior. Every positive survives into the labeled set with probability cc and negatives never do, sop(s=1∣x)=c p(y=1∣x).p(s=1\mid x)=c\,p(y=1\mid x).So ranking by gg is ranking by the posterior, and a team that only needs a ranking never needs cc. Also g≤cg\le c everywhere: even where a point is certainly positive, a fraction 1−c1-c of its copies stay unlabeled, which is why labeled-versus-unlabeled classifiers look badly calibrated. And the prevalence is p(s=1)/cp(s=1)/c, which exceeds the labeled share n/mn/m, as it must.

Step 2

Weighting turns any weighted learner into a PU learner. Instead of rescaling gg, give the learner the data it would have seen with labels, in expectation. A labeled point enters as a positive with weight 1. An unlabeled point enters twice, as a positive with weight w(x)w(x) and as a negative with weight 1−w(x)1-w(x), where Bayes on the event s=0s=0 givesw(x)=p(y=1∣x,s=0)=1−cc g(x)1−g(x).w(x)=p(y=1\mid x,s=0)=\frac{1-c}{c}\,\frac{g(x)}{1-g(x)}.The pair contributes the conditional mean of the loss given xx and s=0s=0, so any empirical risk becomes an estimate of the fully labeled risk given gg and cc, and any learner that takes per-example weights runs unchanged, each weight coming from a formula where the earlier biased SVM searched a grid.

Step 3

C is read off held-out labeled points, and the recommended estimator is exact only for separable classes. The paper recommends e1e_1, the mean of gg over the labeled points of a validation set, for its low variance, arguing that g(x)=cg(x)=c there because y=1y=1. That argument substitutes the realized label for the posterior. Since labeled points follow the positive distribution,E[e1]=c  E[p(y=1∣x)∣y=1]≤c,\mathbb E[e_1]=c\;\mathbb E\big[p(y=1\mid x)\mid y=1\big]\le c,with equality only for separable classes (the reading of Bekker and Davis). A low e1e_1 inflates f=g/e1f=g/e_1, the weights and the prevalence. My check with exact gg, positives N(μ,1)N(\mu,1), negatives N(−μ,1)N(-\mu,1), prevalence 0.3 and c=0.5c=0.5: at μ=1\mu=1, e1≈0.33e_1\approx0.33 and the prevalence estimate n/(m e1)≈0.45n/(m\,e_1)\approx0.45; at μ=2\mu=2, 0.475 and 0.316; at μ=3\mu=3 the bias is gone. The alternative e3=max⁡ge_3=\max g is exact when some region is purely positive, but rests on one point. All of this treats gg as a probability, so it holds only as far as the scores are calibrated; logistic regression stays roughly calibrated even when misspecified, and the paper passes SVM scores through Platt scaling.

Step 4

On one real task both methods nearly match full supervision, far more cheaply than the biased SVM. On transporter proteins with linear SVMs, F1 is 0.947 fully supervised, 0.931 for rescaled gg, 0.942 weighted and 0.928 for the biased SVM, which needs 621 SVM fits per fold against 1 or 2. One data set and one learner show that the methods work and are cheap; they do not show how the methods rank in general.

Setting for the risk estimator. Now Xp∼pp=p(x∣y=+1)X_p\sim p_p=p(x\mid y=+1) (npn_p points) and Xu∼p=πppp+πnpnX_u\sim p=\pi_pp_p+\pi_np_n (nun_u points) are independent, with πp\pi_p known. With Rp±(g)=Ep ℓ(g(X),±1)R_p^\pm(g)=\mathbb E_p\,\ell(g(X),\pm1) and Ru−(g)=EX ℓ(g(X),−1)R_u^-(g)=\mathbb E_X\,\ell(g(X),-1), the identity πnpn=p−πppp\pi_np_n=p-\pi_pp_p removes the missing negatives, πnRn−=Ru−−πpRp−\pi_nR_n^-=R_u^--\pi_pR_p^-. Sample averages give the unbiased PU (uPU) estimator, and clipping the rewritten term gives non-negative PU (nnPU):R^pu(g)=πpR^p+(g)−πpR^p−(g)+R^u−(g),R~pu(g)=πpR^p+(g)+max⁡{0,  R^u−(g)−πpR^p−(g)}.\hat R_{pu}(g)=\pi_p\hat R_p^+(g)-\pi_p\hat R_p^-(g)+\hat R_u^-(g),\qquad \tilde R_{pu}(g)=\pi_p\hat R_p^+(g)+\max\big\{0,\;\hat R_u^-(g)-\pi_p\hat R_p^-(g)\big\}.The theory assumes gg and the loss are bounded (by CℓC_\ell for the loss) and πnRn−(g)≥α>0\pi_nR_n^-(g)\ge\alpha>0.

Step 5

A flexible model makes the unbiased risk negative by learning ss instead of yy. The term R^u−−πpR^p−\hat R_u^--\pi_p\hat R_p^- estimates πnRn−≥0\pi_nR_n^-\ge0, but its two pieces average over different points. A model that can fit individual points scores the labeled positives high, which raises R^p−\hat R_p^-, and every unlabeled point low, positives included, which lowers R^u−\hat R_u^-. With the sigmoid loss this reaches the floor R^pu=−πp\hat R_{pu}=-\pi_p, and with an unbounded loss there is no floor. In the population this solution is impossible; on a sample it is the minimizer, and uPU's guarantees, which need a Rademacher complexity that decays with nn, cannot exclude it. On MNIST even versus odd with 100 labeled positives, a linear model trains and tests fine, while a one-hidden-layer MLP drives the uPU training risk below zero as its test risk rises above that of fully supervised training on 100 positives and 50 negatives. A negative value of the term is pure sampling error, so clipping it is justified.

Step 6

For a fixed classifier, clipping costs an exponentially small bias. The estimators differ only on the event D−(g)D^-(g) where R^u−−πpR^p−<0\hat R_u^--\pi_p\hat R_p^-<0, where the clip adds at most CℓπpC_\ell\pi_p; D−D^- is a lower-tail event for a bounded-difference statistic with mean at least α\alpha, so McDiarmid givesPr⁡(D−(g))≤Δg=exp⁡ ⁣(−2(α/Cℓ)2πp2/np+1/nu),0≤ER~pu(g)−R(g)≤CℓπpΔg,\Pr(D^-(g))\le\Delta_g=\exp\!\Big(-\frac{2(\alpha/C_\ell)^2}{\pi_p^2/n_p+1/n_u}\Big),\qquad 0\le\mathbb E\tilde R_{pu}(g)-R(g)\le C_\ell\pi_p\Delta_g,and R~pu→R\tilde R_{pu}\to R at the CLT rate. The clip matters for the trained classifier, chosen from the data exactly where the term would have gone negative.

Step 7

Clipping lowers the MSE by at least three times the squared amount clipped. Write A=πpR^p+A=\pi_p\hat R_p^+ and B=R^u−−πpR^p−B=\hat R_u^--\pi_p\hat R_p^-, so R^pu=A+B\hat R_{pu}=A+B and R~pu=A+B+\tilde R_{pu}=A+B_+. Expanding both squared errors, everything off D−D^- cancels:MSE(R^pu)−MSE(R~pu)=∫D−(2A+B−2R) B dF.\mathrm{MSE}(\hat R_{pu})-\mathrm{MSE}(\tilde R_{pu})=\int_{D^-}(2A+B-2R)\,B\,dF.Since B<0B<0 on D−D^-, the gain is at least 3∫D−B23\int_{D^-}B^2 once A−R≤BA-R\le B there. A symmetric loss, ℓ(t,+1)+ℓ(t,−1)=1\ell(t,+1)+\ell(t,-1)=1, rewrites the error of AA as A−R=B−2EB+(Ru−−R^u−)A-R=B-2\mathbb EB+(R_u^--\hat R_u^-), which is at most BB when EB≥α\mathbb EB\ge\alpha and the unlabeled average is within 2α2\alpha of its mean. The assumption nu≫npn_u\gg n_p is used here: with many unlabeled points the unlabeled average is accurate, so a negative BB comes from the positive sample, and correcting it moves the estimate toward RR.

Step 8

The estimation-error bound matches uPU's in order, and the gap in constants is a proof artifact. The clipped risk is not an average of per-point losses, so symmetrization does not apply directly. The inequality ∣max⁡{0,z}−max⁡{0,z′}∣≤∣z−z′∣|\max\{0,z\}-\max\{0,z'\}|\le|z-z'| splits a difference of clipped risks into three differences of ordinary partial risks, each handled by symmetrization and Talagrand contraction for an LℓL_\ell-Lipschitz loss. Contraction with the absolute value inside the supremum costs a factor 2. For g~pu=arg⁡min⁡GR~pu\tilde g_{pu}=\arg\min_{\mathcal G}\tilde R_{pu} and g∗=arg⁡min⁡GRg^*=\arg\min_{\mathcal G}R over a class closed under negation, with probability at least 1−δ1-\delta,R(g~pu)−R(g∗)≤16Lℓπp Rnp,pp(G)+8Lℓ Rnu,p(G)+2Cδ′χ+2CℓπpΔ,R(\tilde g_{pu})-R(g^*)\le16L_\ell\pi_p\,\mathfrak R_{n_p,p_p}(\mathcal G)+8L_\ell\,\mathfrak R_{n_u,p}(\mathcal G)+2C'_\delta\chi+2C_\ell\pi_p\Delta,with χ=2πp/np+1/nu\chi=2\pi_p/\sqrt{n_p}+1/\sqrt{n_u}, Cδ′=Cℓln⁡(1/δ)/2C'_\delta=C_\ell\sqrt{\ln(1/\delta)/2} and Δ\Delta the bound of Step 6 with α\alpha from the infimum over the class, against uPU's 8 and 4 with no Δ\Delta term. The authors say plainly that the difference comes from proof technique and says nothing about which minimizer is better. For deep networks, whose Rademacher complexity does not decay at these sample sizes, both bounds are vacuous, so the case for nnPU rests on the experiments.

Step 9

On a mini-batch where the term goes negative, the algorithm steps to raise it, and this fixes deep PU training. Clipping alone gives zero gradient on a batch where it binds, leaving the model where it overfit. Algorithm 1 computes ri=R^u−(g;Xui)−πpR^p−(g;Xpi)r_i=\hat R_u^-(g;X_u^i)-\pi_p\hat R_p^-(g;X_p^i) on each mini-batch; if ri≥−βr_i\ge-\beta it takes an ordinary step on R^pu\hat R_{pu}, and otherwise a step of size γη\gamma\eta along −∇θ(πpR^p−−R^u−)-\nabla_\theta(\pi_p\hat R_p^--\hat R_u^-), which raises rir_i and undoes the memorization on that batch. With β=0\beta=0, γ=1\gamma=1 and 1,000 labeled positives, uPU overfits on all four data sets (MNIST, epsilon, 20News, CIFAR-10) and nnPU does not, beating fully supervised learning with nn=(πn/2πp)2npn_n=(\pi_n/2\pi_p)^2n_p negatives on three and tying on 20News. With πp\pi_p misspecified from 0.8πp0.8\pi_p to 1.2πp1.2\pi_p, underestimates hurt more than overestimates; the authors explain that a larger prior makes the clip bind more often, moving the method further from the overfitting uPU at the cost of more bias.

Consequences and limits. nnPU became the default PU objective for deep models, and both methods rest on SCAR. Under selected-at-random labeling the propensity e(x)=p(s=1∣x,y=1)e(x)=p(s=1\mid x,y=1) varies and the data identify only the productp(s=1∣x)=e(x) p(y=1∣x),p(s=1\mid x)=e(x)\,p(y=1\mid x),so dividing by a constant can reverse rankings, pushing rarely labeled positives below often labeled ones. For nnPU the labeled sample then comes from e(x)pp(x)/ce(x)p_p(x)/c, the rewrite subtracts the wrong positive mass, and the estimator is biased however large the samples. Without a further assumption neither the posterior nor the prior is identified (Bekker and Davis), and even under SCAR the prior needs something like irreducibility or a purely positive region. Payment fraud puts SCAR in question: chargebacks are the labeled positives, unreported fraud sits in the unlabeled pool, reporting rates plausibly vary with amount, card type and how closely the cardholder reads statements, and recent transactions have had less time to be reported. Only the age effect is tractable, because the delays of chargebacks on older, matured transactions show how the propensity grows with age relative to the eventual reporting rate. Amount and card type are recorded, but PU data alone do not say how reporting varies with them, and attentiveness is not recorded at all, the case where the data cannot separate fraud that is rare from fraud that goes unreported. The prior nnPU needs is the true fraud rate including what is never reported, which no one observes, and the misspecification results suggest erring high. A flexible scorer fit to the unbiased objective will memorize the labeled frauds, and the batch quantity R^u−−πpR^p−\hat R_u^--\pi_p\hat R_p^- going negative in training is a direct warning that it has.

Terms

SCAR
p(s=1∣x,y=1)=cp(s=1\mid x,y=1)=c for all xx; labeling is a constant thinning of the positives
cc, label frequency
p(s=1∣y=1)p(s=1\mid y=1); the one number the PU problem reduces to
g(x)g(x)
nontraditional classifier, labeled vs unlabeled; estimates p(s=1∣x)≤cp(s=1\mid x)\le c
The lemma
under SCAR, p(y=1∣x)=g(x)/cp(y=1\mid x)=g(x)/c; same ranking as gg
e1e_1
mean of gg on held-out labeled points; equals c E[p(y=1∣x)∣y=1]c\,\mathbb E[p(y=1\mid x)\mid y=1], so exact only for separable classes
w(x)w(x)
p(y=1∣x,s=0)=1−ccg1−gp(y=1\mid x,s=0)=\frac{1-c}{c}\frac{g}{1-g}; weight of an unlabeled point as a positive
SAR, propensity e(x)e(x)
p(s=1∣x,y=1)p(s=1\mid x,y=1) varies with xx; data identify only e(x)p(y=1∣x)e(x)p(y=1\mid x)
Key rewrite
πnRn−(g)=Ru−(g)−πpRp−(g)\pi_nR_n^-(g)=R_u^-(g)-\pi_pR_p^-(g), the negative-class risk without negatives
uPU
R^pu=πpR^p+−πpR^p−+R^u−\hat R_{pu}=\pi_p\hat R_p^+-\pi_p\hat R_p^-+\hat R_u^-; unbiased, can go negative
nnPU
R~pu=πpR^p++max⁡{0,R^u−−πpR^p−}\tilde R_{pu}=\pi_p\hat R_p^++\max\{0,\hat R_u^--\pi_p\hat R_p^-\}; biased upward, consistent

Quiz

  1. A team only needs to rank unlabeled records by how likely they are to be positive. Under SCAR, why can they use the labeled-versus-unlabeled classifier gg without estimating cc?
  2. Labels follow a propensity e(x)=p(s=1∣x,y=1)e(x)=p(s=1\mid x,y=1) that is high in region A and low in region B. What goes wrong if one applies g/cg/c anyway?
  3. Why is clipping R^u−−πpR^p−\hat R_u^--\pi_p\hat R_p^- at zero a principled change and not an arbitrary penalty?
  4. When the supplied prior is wrong, overestimating πp\pi_p hurt nnPU less than underestimating it. What is the authors' explanation?

Sources