Inferensys

Glossary

Tomek Links

A data cleaning method that identifies pairs of minimally distanced nearest neighbors of opposite classes and removes the majority class instance to clarify the decision boundary between overlapping classes.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
BOUNDARY CLARIFICATION

What is Tomek Links?

A data cleaning method that identifies pairs of minimally distanced nearest neighbors of opposite classes and removes the majority class instance to clarify the decision boundary between overlapping classes.

A Tomek Link is defined as a pair of minimally distanced nearest neighbors from opposite classes. If two instances, one from the majority class and one from the minority class, are each other's closest neighbor in the feature space, they form a Tomek Link. These pairs typically represent overlapping regions or noisy points along the class boundary, where the distinction between fraud and legitimate activity is ambiguous.

The Tomek Links algorithm resolves this ambiguity by removing the majority class instance from each identified pair. This acts as a targeted under-sampling technique that does not blindly reduce the majority class size but specifically eliminates borderline and overlapping examples. The result is a cleaner, less noisy dataset with a more well-defined separation between classes, which often improves the performance of classifiers like k-nearest neighbors.

BOUNDARY CLARIFICATION

Key Characteristics of Tomek Links

Tomek Links are a data cleaning method that identifies pairs of minimally distanced nearest neighbors of opposite classes and removes the majority class instance to clarify the decision boundary between overlapping classes.

01

Definition and Core Mechanism

A Tomek Link is defined as a pair of instances (x, y) from opposite classes where no other instance z exists such that the distance d(x, z) < d(x, y) or d(y, z) < d(y, x). In simpler terms, two instances from different classes are each other's nearest neighbor. The core mechanism involves identifying all such pairs and systematically removing the majority class instance from each link. This process directly eliminates overlapping or ambiguous data points that sit exactly on or within the wrong side of the decision boundary, reducing noise and creating a cleaner, more separable class margin for subsequent classifiers.

02

Mathematical Foundation and Distance Metrics

The algorithm relies on computing a pairwise distance matrix, typically using Euclidean distance for continuous features, though other metrics like Manhattan or Mahalanobis distance can be applied. For each instance, its nearest neighbor is identified. A Tomek Link is formed if and only if two instances are mutual nearest neighbors and belong to different classes. The computational complexity is O(n²) for a naive implementation, making it expensive for very large datasets. Efficient implementations often use k-d trees or ball trees to accelerate the nearest neighbor search, reducing the average complexity to O(n log n).

03

Effect on the Decision Boundary

By removing majority class instances that intrude into the minority class space, Tomek Links effectively prune the decision boundary. This has two primary effects:

  • Noise Reduction: Eliminates borderline and ambiguous majority examples that cause overfitting.
  • Margin Maximization: Creates a clearer separation zone between classes, which is particularly beneficial for margin-based classifiers like Support Vector Machines (SVMs). The result is not a balanced dataset but a cleaner one. The class distribution remains imbalanced, but the overlap between classes is significantly reduced, allowing the classifier to learn a more generalizable boundary.
04

Integration in Hybrid Resampling: SMOTETomek

Tomek Links are rarely used in isolation for imbalanced classification. Their most common application is as the second step in the SMOTETomek hybrid pipeline. This combined method first applies SMOTE to oversample the minority class, creating synthetic examples. However, SMOTE can inadvertently create samples that invade the majority class space, introducing new noise. Applying Tomek Links after SMOTE cleans up this noise by removing the overlapping majority class instances that now sit too close to the new synthetic minority points. This two-step process creates a balanced and well-separated dataset.

05

Limitations and Practical Considerations

Despite its utility, Tomek Links has key limitations:

  • Computational Cost: The O(n²) pairwise distance calculation is prohibitive for datasets with millions of transactions.
  • Information Loss: Removing majority class instances can discard valuable information, especially if the overlapping region is large and represents a genuine area of class ambiguity rather than noise.
  • No Minority Handling: It only removes majority class samples. Noisy minority class examples that sit deep within the majority space are untouched, potentially acting as outliers that distort the boundary.
  • Metric Sensitivity: The definition of a 'link' is highly sensitive to the chosen distance metric and the scale of features, making feature normalization a critical prerequisite.
06

Comparison with Edited Nearest Neighbors (ENN)

While both are under-sampling methods that clean the majority class, they operate on different principles:

  • Tomek Links: Removes only the majority instance from a pair of mutual nearest neighbors of opposite classes. It focuses on the exact boundary line.
  • Edited Nearest Neighbors (ENN): Removes any majority instance whose predicted class (based on a k-nearest neighbor vote) differs from its actual class. It cleans a wider region around the boundary. ENN is generally more aggressive in removing majority samples, while Tomek Links is more conservative, only eliminating the most ambiguous, directly opposed pairs. They are often combined in the One-Sided Selection algorithm.
COMPARATIVE ANALYSIS

Tomek Links vs. Other Under-Sampling Methods

A feature-level comparison of Tomek Links against other common under-sampling strategies for clarifying decision boundaries in imbalanced classification.

FeatureTomek LinksEdited Nearest NeighborsNearMissRandom Undersampling

Removal Criterion

Opposite-class nearest neighbor pairs

Misclassified by k-NN consensus

Distance to minority class instances

Random selection

Preserves Decision Boundary

Removes Majority Class Noise

Removes Redundant Majority Instances

Computational Complexity

O(n^2) pairwise distance

O(k * n * d) per iteration

O(n * m) distance computation

O(n) random selection

Risk of Information Loss

Low

Moderate

Moderate to High

High

Handles High-Dimensional Data

Deterministic Output

TOMEK LINKS

Frequently Asked Questions

Clear, concise answers to the most common technical questions about Tomek Links, their role in imbalanced classification, and how they improve fraud detection models.

A Tomek Link is a pair of minimally distanced nearest neighbors of opposite classes. Specifically, two instances E_i and E_j belonging to different classes form a Tomek Link if no other instance E_l exists such that the distance d(E_i, E_l) < d(E_i, E_j) or d(E_j, E_l) < d(E_i, E_j). In practice, these pairs represent points that lie exactly on or very near the class boundary, often representing overlapping regions or noisy samples. The standard Tomek Links algorithm removes only the majority class instance from each pair, effectively cleaning the decision boundary by eliminating ambiguous majority samples that intrude into the minority class space. This clarifies the separation surface for downstream classifiers.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.