What is a Tomek link?
Last updated
A Tomek link is a pair of samples from opposite classes that are each other's nearest neighbor. Such pairs sit on the class boundary or indicate noise, so removing them cleans up class overlap.
Definition:
Samples
a(class 0) andb(class 1) form a link if no samplexsatisfiesd(a,x) < d(a,b)ord(b,x) < d(a,b).Put simply, they are mutual 1-nearest neighbors with different labels.
Interpretation: either both points lie right on the boundary, or one of them is noise or mislabeled.
Use as undersampling:
Typically only the majority member is removed, which widens the margin around minority points.
Removing both members is used for pure data cleaning, for example after SMOTE.
Limitations:
It removes only a few samples, so it is a cleaning step, not a way to reach balance.
It depends on a meaningful distance metric, so features must be scaled.
In
imbalanced-learn, useTomekLinks(sampling_strategy='auto'), which removes majority members by default.