Context. By 2001 cost-sensitive learning had many algorithms but loose foundations: published cost matrices mixed baselines, and rebalancing the training set was a common practice with no formula for how much. Elkan's short paper settles the two-class case. A year later Saerens et al. take up the companion problem: a classifier trained on a sample drawn by class (a case-control study, a deliberately balanced training set) reports posteriors at the training priors, and the deployment priors are usually unknown because the deployment labels are. Costs and base rates enter only through the threshold applied to , so the learner should estimate that probability well and the threshold is set at decision time, per example if the costs vary. Rebalancing the training set and moving to a new base rate are the same odds multiplication, which for the learners Elkan analyzes can be done after training, and when the new base rate is unknown it is the fixed point of "average the corrected posteriors" over the unlabeled deployment data.
Setting. is the cost of predicting class when the true class is , and the optimal prediction minimizes . Under the reasonableness conditions and (a mistake costs more than the correct label), predict class 1 if and only if , with For priors, classes have training priors , the model's outputs satisfy , and the within-class densities do not change between training and deployment, (label shift), which holds when the training set was selected on the class and not on .
The decision is a threshold, and the cost matrix carries one number. Predicting 1 is optimal when , which rearranges to . Adding to the column of true class adds to both actions' expected costs (our reading, stronger than the paper's scaling and shifting invariance), so only the regrets and matter, and only through their ratio. Reasonableness puts in with class 1 predicted above it; a class whose row is entrywise at least another's is never worth predicting.
Costs need one baseline, and they can vary by example. The German credit matrix charges 1 for rejecting a good applicant, 5 for approving a bad one, and 0 on the diagonal. But denying a loan produces the same cash flow whatever the applicant would have done, so in a coherent matrix both entries of the "predict bad" row are equal; measuring benefits from the state before the decision avoids the error. In Elkan's card example, refusing a fraud is worth , refusing a legitimate customer , approving a fraud and a legitimate purchase for amount , and Step 1 gives which is 0.5 at , about 15% at \$100, about 3.8% at \$1,000, and tends to 2%. A threshold that moves with each transaction cannot come from any single rebalancing of the training set, only from a probability plus a per-example decision.
Under label shift the posterior is the old one reweighted by the prior ratio (Elkan's Theorem 2, and Saerens' correction). Equate the class densities in Bayes for the two populations, . The unknown factor is common to all classes and fixed by normalization, sowith the old and new base rates. Elkan's page of algebra is this one line, and it uses nothing about the learner. He reads it as relaxing the assumption that training and test come from one population; it relaxes it only to label shift, where the class proportions move and nothing else does. In logits the correction adds the log prior ratio to each class, which is also the logit adjustment of Menon et al. (later in this section).
Rebalancing is a threshold move (Elkan's Theorem 1). Thinning the negatives is a base-rate change, so Step 3 applies. Multiplying the negatives by without changing their distribution divides the training odds by , so a learner's rule reads , and making it act as needswhich is for an accuracy learner with a zero diagonal (Breiman et al., 1984). With and an accuracy learner, keep one negative in 19 or weight negatives by 1/19. Read backward, a model trained with negatives kept at rate reports odds inflated by , and multiplying its odds by recovers the population probability. Both directions need the thinning to leave alone: random sampling or weights do, while choices that correlate with (keeping only low-score negatives, say) break the theorem.
For learners that estimate probabilities, rebalancing changes little. This part is argued, without experiments. A Bayesian classifier models each separately, so rebalancing changes only the estimated , exactly a threshold move; naive Bayes ranks well but gives probabilities that are too extreme, so its threshold should be set empirically, which rebalancing to 0.5 cannot do. For tree splits with impurity , Bayes inside each branch givesso at the base rates factor out and the best split ignores them (Theorem 3), while for Gini () the mixture brings them back. Prevalence matters at pruning instead, where C4.5 often reduces a tree with a rare class to a single leaf predicting the common class, and Laplace pruning (smooth a leaf with positives out of to , prune when the parent's expected loss is below the children's total) is close to no pruning: without smoothing a parent's expected loss is never below its children's total, since the minimum of an average is at least the average of the minima. Hence the recommendation: train on the data as given, smooth the probabilities, and apply the threshold per example.
With unknown new priors, the likelihood in the priors is concave and EM finds its maximum. By the identity of Step 3, a deployment point has with , and does not involve , soThe classifier never has to produce a density, because is up to a factor common to all classes. A sum of logs of linear functions is concave on the simplex, so the paper's worry that EM might stop at a local maximum does not apply (our observation, the standard fact about mixture weights with fixed components). EM treats the deployment labels as missing: the E-step computes the corrected posteriors at the current priors, and the M-step setsstarting from the training priors. A fixed point solves the score equation multiplied by , and EM started inside the simplex converges to the maximizer, linearly and more slowly when the classes overlap; five iterations sufficed in the paper. The M-step shows how errors propagate: the estimated prior averages posteriors over the whole deployment set, so a systematic calibration error on the bulk of one class passes straight into it.
The competing method matches moments of hard decisions, and a likelihood ratio test asks whether the priors moved. The confusion-matrix method solves for the new priors, using that a decision is a function of , so its class-conditional law survives label shift. It needs only an invertible confusion matrix, so it stays consistent for a miscalibrated classifier, which EM does not (Lipton et al., shift section). Here the matrix is estimated on the training set, where the classifier looks more accurate than it is (both error rates too small), which plausibly pulls its estimates toward the balanced training prior (our reading, not tested in the paper). For the test, the shared factor cancels andis referred to under unchanged priors (Wilks); the paper adjusts only when it rejects, since adjusting under no shift cost a little accuracy. The null ignores miscalibration of the outputs, so on a very large deployment set a small calibration error alone will produce a rejection.
In the experiments, estimated priors shrink toward 50%, EM less than the confusion matrix, and adjustment recovers most of the lost accuracy. On Ringnorm with a small network trained on balanced data, a true 10% prior was estimated at 14.7% by EM and 18.1% by the confusion matrix, and accuracy rose from 90.1% unadjusted to 93.6% with EM, against 94.0% with the true priors; the test rejected in every shifted run and in none at 50%. On three medical data sets trained 50/50 and tested at 20/80, adjustment always helped. Nothing here covers priors below 10% or shifts that are not pure label shift.
Consequences and limits. The lasting content is the separation of estimation from decision, with rebalancing and prior shift reduced to odds corrections that do not improve the learner. For payment fraud, decline when , with set per transaction by the loss on an approved fraud against the cost of declining a good customer. A model trained with legitimate traffic kept at rate needs its odds multiplied by first, and when the live fraud rate moves, EM on the day's scores estimates it long before chargebacks label the traffic, with the test as an inexpensive check that it has moved. But fraud shift is rarely pure label shift: a new attack changes , EM reports it as a change in prevalence, and the test says only that something moved. With fraud at a fraction of a percent, the EM estimate also averages posteriors over millions of legitimate transactions, so a calibration error on them of the same order as the prevalence corrupts it, and calibration (later in this section) becomes a prerequisite; Alexandari et al. (2020) found EM on recalibrated outputs hard to beat. The claim that rebalancing has little effect is argued for naive Bayes and trees only; for a misspecified discriminative model it is false: Fithian and Hastie (later in this section) show that subsampling changes what a misspecified logistic regression converges to, enough to reverse a coefficient's sign, and suggest using the effect on purpose to aim the fit at the decision threshold.
Terms
- cost of predicting class when the truth is ; false positive, false negative
- ; predict positive iff
- regrets
- and ; the decision depends only on their ratio
- common baseline
- every cost measured from the state before the decision; a reject row has equal entries
- Theorem 2
- Theorem 1
- multiply negatives by to make threshold act as
- subsampling correction
- negatives kept at rate : multiply the model's odds by
- ; concave, so the EM limit is the global MLE
- confusion-matrix method
- solve ; needs invertibility; calibration is not required
- calibration requirement
- EM's estimate inherits any systematic error in the posteriors, strongly for a rare class
Quiz
- A fraud model was trained on all frauds and 1 in 50 legitimate transactions, kept at random. It outputs 0.20 for a transaction. What is the population fraud probability?Keeping negatives at rate multiplies the training odds by , so the population odds are and the probability is . Dividing the probability instead of the odds is off by the factor ; the two agree only when the score itself is small.
- A team keeps all frauds and only the legitimate transactions their old model scored lowest, then applies the Theorem 2 odds correction. What goes wrong?Both theorems need the thinning to leave the distribution of within the negatives unchanged. Selecting negatives on a score that depends on changes in the training set, and the odds identity no longer holds.
- Fraud is 0.1% of transactions. Why can EM's prior estimate be badly off even with a classifier that ranks well?The M-step sets the prior to the mean corrected posterior. A systematic error of order on the 99.9% of legitimate transactions moves that mean by the same order as the prevalence being estimated.
- A new attack type pushes fraud from 0.2% to 0.4%, with features unlike past fraud. What does the EM procedure deliver?EM fits only the mixture weights of fixed class densities. When the fraud density itself moves, the fitted weights absorb the misfit, and a significant test says only that something changed.
Sources
- Charles Elkan. The Foundations of Cost-Sensitive Learning. IJCAI, 2001.
- Marco Saerens, Patrice Latinne, and Christine Decaestecker. Adjusting the Outputs of a Classifier to New a Priori Probabilities: A Simple Procedure. Neural Computation, 2002.
- Leo Breiman, Jerome H. Friedman, Richard A. Olshen, and Charles J. Stone. Classification and Regression Trees. Wadsworth, 1984.
- Amr Alexandari, Anshul Kundaje, and Avanti Shrikumar. Maximum Likelihood with Bias-Corrected Calibration is Hard-To-Beat at Label Shift Adaptation. ICML, 2020.