Skip to content
Preptima
hardConceptMidSeniorStaff

Class weights, oversampling, undersampling, SMOTE. What does each one cost you?

None of them adds information. Weights change the loss without touching the data, oversampling duplicates rows and inflates any score computed after it, undersampling discards real observations, and SMOTE interpolates implausible points. All shift the implied prior, so the scores need recalibrating.

5 min readUpdated 2026-07-28
Practice answering out loud

What the interviewer is scoring

  • Whether the candidate states that none of these techniques creates information
  • Does the answer place the resampling inside the cross-validation fold and explain what happens if it is outside
  • That the effect on predicted probabilities is quantified and a correction named
  • Whether SMOTE's geometric assumption is examined against categorical and high-dimensional features
  • Can the candidate say what they would try before reaching for any of these

Answer

The common property worth stating first

All four techniques change how the learner sees an existing dataset, and none adds a single new observation about the minority class. If you have 300 frauds, you have 300 frauds whether you weight them at 200, duplicate them to 60,000, throw away most of your negatives, or interpolate synthetic neighbours between them. The information content is fixed and everything here redistributes emphasis within it.

Saying that up front is worth more than the taxonomy that follows, because the failure these techniques are usually deployed against is not imbalance. It is a threshold left at 0.5, a metric that cannot see the minority class, and a model that ranks perfectly well already.

Class weights

Multiplying the loss contribution of minority examples changes the gradient without touching the data. Nothing is duplicated, nothing is discarded, and both the row count and the training time are unchanged. That makes it the cheapest option and the sensible default when you want the optimiser to stop ignoring 0.05% of the loss.

Its cost is that it changes what the model is estimating. Weighting positives by 200 tells the learner that a positive error is 200 times worse, which is a statement about costs, so the resulting scores estimate a reweighted quantity rather than the posterior probability. Ranking is largely preserved, which is why AUC often barely moves, and that surprises people who expected weights to make the model better rather than merely more attentive.

Oversampling by duplication

Copying minority rows until the classes balance is trivially simple and has two costs. The first is overfitting to the exact copies: a tree can isolate a duplicated row in a leaf and be rewarded many times over for memorising it, which is why oversampling helps less on high-capacity models than people expect.

The second is a genuine leak. Resample first and split afterwards, and copies of the same row land on both sides, so the model has literally seen the validation rows and the reported score is worthless. The resampling belongs inside the cross-validation fold, applied to the training portion only, which in practice means inside a pipeline whose steps are refitted per fold.

Undersampling

Discarding majority rows shrinks the training set, which is fast and information-destroying in a way the others are not. With 2,000 positives and 3,998,000 negatives, balancing by undersampling leaves you training on 4,000 rows out of four million, and every discarded negative was a real observation of how ordinary behaviour looks.

Mitigate it by undersampling less aggressively, to a ratio like 1:10 rather than 1:1, or by bagging several models trained on disjoint negative samples so the ensemble collectively sees all the majority data. On a very large dataset where the majority is genuinely redundant it also has the best compute economics of the four.

SMOTE and its geometric assumption

SMOTE creates synthetic minority points by taking a minority example, choosing one of its k nearest minority neighbours, and placing a new point at a random position on the line segment between them. The premise is that the space between two minority examples is also minority space.

That premise is a real assumption and it fails in identifiable ways. On one-hot encoded columns the interpolation produces values like 0.37 for a column that can only be 0 or 1, so the synthetic row is a customer 37% resident in one region, which corresponds to nothing and which trees will happily split on. On high-dimensional data, nearest neighbours become nearly equidistant, so the chosen neighbour is close to arbitrary and the segment between them can pass straight through majority territory. Where the minority class is multi-modal, interpolating between two modes generates points in the gap, which is exactly the region no real positive occupies.

Where it works, it works because the minority region is roughly convex and continuous in the feature space you gave it, and that is a claim you can check by seeing whether the synthetic points fall among real ones. Variants that restrict generation to the boundary region, or that take the majority category rather than interpolating one, address the specific failures rather than the assumption itself.

The prior shift, with the correction derived

Every resampling scheme changes the base rate the model was fitted on, so its output probabilities are estimates for a population that does not exist. This is the step most answers omit, and it is measurable. Take undersampling: keep all 2,000 positives and sample 2,000 negatives from 3,998,000, so the negative sampling rate is

r  =  2000 / 3998000  =  1 / 1999

Because positives are kept at rate 1 and negatives at rate r, the odds the model learns are inflated by exactly 1/r. Recovering the true odds means multiplying the model's odds by r:

model output p_s = 0.90   ->   odds_s = 0.90 / 0.10 = 9
true odds = 9 x (1/1999) = 0.004502
true p    = 0.004502 / 1.004502 = 0.00448

So a case the model reports at 90% is a case with a 0.45% chance of being fraud. Every cost-based threshold, every expected-value calculation and every risk figure quoted to a human is wrong by that factor until the correction is applied. Class weighting produces an analogous shift with the weight ratio in place of the sampling ratio.

Two consequences follow. Apply the analytic correction where the sampling scheme is known exactly, and otherwise fit isotonic or Platt scaling on a held-out set drawn at the true prevalence. And evaluate at the true prevalence regardless, because precision computed on a balanced evaluation set is a number from the same nonexistent world.

What to try before any of this

Order the interventions by cost. Setting the threshold from the real cost ratio is free and fixes the most common complaint about imbalanced models. Reporting precision and recall at the operating point instead of accuracy is also free. Class weights are nearly free. Only if the minority class is so small that the optimiser genuinely cannot find it does resampling earn its place, and then expect to recalibrate afterwards.

Above all, more real positives beats all of it. Better labelling of ambiguous cases, a second outcome source, and randomised review sampling to surface unlabelled positives add information, which nothing in this answer does.

Resampling and weighting redistribute emphasis, they do not create data, and every one of them shifts the prior the model was fitted on. Put them inside the fold and recalibrate before treating a single output as a probability.

Likely follow-ups

  • Derive the prior correction for a model trained on undersampled negatives.
  • Why does class weighting move AUC so little compared with how much it moves the loss?
  • What does SMOTE do to a one-hot encoded column, and why is that a problem?
  • When is collecting or buying more positives cheaper than any of these techniques?

Related questions

Further reading

class-imbalancesmoteresamplingclass-weightscalibration