Quant Memo
Advanced

Sample Weights & Label Uniqueness

Overlapping labels make financial observations redundant, not independent. Weighting each sample by how little its label overlaps the others stops the model from over-counting near-duplicate data.

Prerequisites: Triple-Barrier Labeling, Purged & Embargoed Cross-Validation

Almost every machine-learning algorithm assumes its training rows are independent draws, each observation is a fresh, separate piece of evidence. In finance that assumption is quietly false, and the reason is labeling. When you tag each observation with a forward-looking outcome, say the triple-barrier label over the next five days, then two observations one day apart are labeled from almost the same price path. They are not independent evidence; they are near-duplicates. Feed them to a model as if they were separate and it will over-count that stretch of history, becoming falsely confident about a period it effectively saw once.

Sample-weight and uniqueness methods fix this. The idea: measure how much each label overlaps its neighbors, and down-weight the ones that share their outcome with many others. A label that stands alone counts fully; a label buried in a pile of overlapping labels counts for a fraction.

Concurrency and uniqueness

Give each observation ii a label span [ti,0,ti,1][t_{i,0}, t_{i,1}], the stretch of time whose price path determines its label. Now count, at every instant tt, how many labels are "live":

ct=i1{t[ti,0,ti,1]}.c_t = \sum_i \mathbf{1}\{\, t \in [t_{i,0},\, t_{i,1}]\,\}.

This ctc_t is the concurrency, the number of labels overlapping at time tt. At a moment where three labels overlap, each of them owns only 1/31/3 of that instant's information. A label's average uniqueness is just the average of 1/ct1/c_t across its own span:

uˉi=1ti,1ti,0ti,0ti,11ctdt,\bar u_i = \frac{1}{t_{i,1} - t_{i,0}} \int_{t_{i,0}}^{t_{i,1}} \frac{1}{c_t}\, dt,

which reads as: over the life of label ii, how much of the information did it have to itself on average. A perfectly isolated label has uˉi=1\bar u_i = 1; a label that spends its whole life sharing time with one other has uˉi=0.5\bar u_i = 0.5. You then train with sample weights proportional to uˉi\bar u_i, so redundant observations pull less.

L1 L2 L3 c=1 c=2 c=1 0 2 4 6 8 time (days)
Three five-day labels and the concurrency count beneath them. L2 lives entirely inside the doubly-overlapped stretch, so it is the least unique and gets the smallest training weight; L1 and L3 each spend half their life alone, so they count for more.

Financial labels overlap, so observations are redundant, not independent. Weight each sample by its average uniqueness uˉi\bar u_i, the average of 1/ct1/c_t over its label span, so a pile of near-duplicate labels does not swamp the model with repeated evidence.

Worked example: three overlapping labels

Take the picture above: three labels, each spanning 4 days.

  • L1 covers days 0–4. From day 0 to 2 it is alone (c=1c = 1); from day 2 to 4 it overlaps L2 (c=2c = 2). Its uniqueness is the average of 1/c1/c: 14(1+1+12+12)=34=0.75\tfrac{1}{4}\big(1 + 1 + \tfrac12 + \tfrac12\big) = \tfrac{3}{4} = 0.75.
  • L2 covers days 2–6 and spends its entire life in the doubly-overlapped stretch (c=2c = 2 throughout). Its uniqueness is 14(12+12+12+12)=0.50\tfrac{1}{4}\big(\tfrac12 + \tfrac12 + \tfrac12 + \tfrac12\big) = 0.50.
  • L3 covers days 4–8, mirroring L1: half overlapped, half alone, so uˉ=0.75\bar u = 0.75.

Normalize these into training weights by dividing by their sum (0.75+0.50+0.75=2.00.75 + 0.50 + 0.75 = 2.0):

wL1=0.375,wL2=0.25,wL3=0.375.w_{L1} = 0.375,\quad w_{L2} = 0.25,\quad w_{L3} = 0.375.

L2, the label that never had any information to itself, contributes a third less than each of its neighbors. Without this correction the model would treat all three as equal, over-weighting the crowded middle of the sample and learning a distorted picture. This single reweighting is often the difference between a forest that trusts its data appropriately and one that is quietly over-confident.

Where it plugs in

  • The bagging bootstrap. Random forests bootstrap-sample the data assuming independence. With overlapping labels the resamples draw the same information repeatedly, so the trees are far more correlated than the algorithm believes and the forest is effectively smaller. López de Prado's sequential bootstrap draws observations with probability tilted toward high uniqueness, restoring the diversity bagging needs.
  • Time decay. Old information usually matters less. Multiply the uniqueness weight by a decay factor so recent, unique observations dominate, without discarding history entirely.
  • Return attribution. You can further scale weights by the absolute return realized over the label span, so observations tied to larger, more informative moves count for more than flat ones.

Pitfalls

  • Ignoring it entirely. The default, equal weights, silently over-counts overlapping stretches and inflates confidence, exactly the trap that makes a backtest look better than reality.
  • Wrong label spans. Uniqueness depends on [ti,0,ti,1][t_{i,0}, t_{i,1}]. If a triple-barrier label actually closed early when a barrier was touched but you recorded the full horizon, the concurrency is miscounted and the weights are wrong.
  • Double-correcting. Uniqueness weighting and purging address related but distinct leaks: uniqueness fixes redundancy within training, purging fixes overlap across the train/test boundary. You need both, and neither replaces the other.
  • Reading importance off weighted models. Sample weights change which features look important; interpret feature importance in light of the weighting, not against an unweighted baseline.

Uniqueness weighting corrects for redundancy inside your training set; it does nothing about leakage into the test set. Overlapping labels also corrupt cross-validation, which is why you still need Purged & Embargoed Cross-Validation on top. Treat the two as partners, not substitutes.

A quick health check: compute the average uniqueness across your whole sample. If it is far below 1 (say 0.3), your effective sample size is roughly that fraction of your row count, a dataset of 10,000 overlapping labels may carry only ~3,000 independent observations. That number is a sobering, and honest, input to any backtest-overfitting calculation.

Related concepts

Practice in interviews

Further reading

  • López de Prado, Advances in Financial Machine Learning (Ch. 4)
  • López de Prado, The 10 Reasons Most Machine Learning Funds Fail
  • Hastie, Tibshirani & Friedman, The Elements of Statistical Learning (Ch. 8)
ShareTwitterLinkedIn