Edited Nearest Neighbors (ENN) is an undersampling technique that removes any majority class example whose predicted class, based on its k-nearest neighbors, differs from its actual class. The algorithm iterates through the dataset, classifies each instance using a k-NN rule (typically k=3), and discards misclassified majority samples. This process eliminates noisy instances and class overlap, clarifying the decision boundary without artificially generating new data points.
Glossary
Edited Nearest Neighbors

What is Edited Nearest Neighbors?
Edited Nearest Neighbors (ENN) is a data-level undersampling algorithm that cleans a dataset by removing majority class examples whose class label differs from the majority class of its k-nearest neighbors, effectively eliminating noisy or ambiguous instances near the decision boundary.
ENN is often used as a data cleaning step rather than a standalone balancing method, as it removes fewer examples than aggressive undersampling techniques. It is frequently combined with oversampling methods like SMOTE in hybrid approaches such as SMOTEENN, where ENN cleans the augmented dataset of overlapping or ambiguous synthetic samples. The result is a cleaner, more separable feature space that improves classifier generalization on imbalanced problems like financial fraud anomaly detection.
Key Characteristics of ENN
Edited Nearest Neighbors (ENN) is a noise-removal under-sampling algorithm that refines the majority class by discarding instances that disagree with their local neighborhood, clarifying the decision boundary for downstream classifiers.
The Core Algorithm: k-NN Voting
ENN operates by iterating through every instance in the dataset. For each data point, it finds its k nearest neighbors (typically k=3). If the instance's actual class label does not match the majority vote of its neighbors, it is considered noisy or ambiguous and is removed. This process exclusively targets majority class examples for deletion, leaving minority class instances untouched to preserve rare event information.
Noise Elimination vs. Boundary Clarification
The primary goal of ENN is to smooth the decision boundary. By removing majority class points that intrude deeply into minority class space, ENN eliminates overlapping regions. This is distinct from simple random under-sampling:
- Noise Removal: Deletes mislabeled or ambiguous majority instances.
- Boundary Cleaning: Removes majority points surrounded by minority neighbors, making the class separation more distinct for algorithms like k-NN or SVM.
Integration in Hybrid Pipelines
ENN is rarely used in isolation. It is a critical component of combined resampling strategies designed to address severe class imbalance:
- SMOTEENN: Applies SMOTE to oversample the minority class, then immediately uses ENN to clean the resulting dataset of any noisy synthetic or original majority points.
- Neighborhood Cleaning Rule (NCR): Uses ENN as a first pass to clean the majority class, followed by a second pass that removes minority class examples misclassified by its three nearest neighbors.
Computational Considerations
The ENN algorithm requires calculating the k-nearest neighbors for every single instance in the dataset. This results in a computational complexity of O(n²) for a brute-force search, making it slow on large-scale financial transaction datasets. In practice, optimized spatial indexing structures like k-d trees or ball trees are used to accelerate the neighbor search, but the method remains more computationally intensive than simple random under-sampling.
Impact on Model Sensitivity
By removing ambiguous majority class examples, ENN typically increases the true positive rate (recall) for the minority class. The classifier is no longer confused by overlapping instances, allowing it to draw a more aggressive boundary. However, aggressive cleaning can also increase the false positive rate if the boundary becomes too tightly wrapped around the minority class. The choice of k is critical: a smaller k removes more instances, while a larger k is more conservative.
ENN vs. Tomek Links
Both are data cleaning methods, but they operate on different principles:
- ENN: Removes a majority instance if its class differs from the plurality of its k neighbors. It can remove multiple majority points in a dense overlapping region.
- Tomek Links: Identifies pairs of minimally distanced opposite-class instances and removes only the majority class instance in the pair. It is a more conservative, pair-wise cleaning strategy that focuses strictly on the borderline.
Frequently Asked Questions
Clear, technical answers to the most common questions about the Edited Nearest Neighbors (ENN) algorithm, its mechanics, and its role in cleaning imbalanced datasets for robust fraud detection models.
Edited Nearest Neighbors (ENN) is a data cleaning algorithm that removes noisy or ambiguous majority class examples from a dataset. It works by evaluating each instance against its k-nearest neighbors (typically k=3). If the instance's actual class label differs from the class predicted by the majority vote of its neighbors, that instance is considered noisy or borderline and is removed from the dataset. The algorithm iterates through every example in the training set, retaining only those whose class label is consistent with their local neighborhood. This process effectively 'edits' the dataset, eliminating overlapping instances that blur the decision boundary between classes. In the context of financial fraud detection, ENN is primarily used as an under-sampling technique to clean the majority (non-fraud) class, removing legitimate transactions that look suspiciously like fraud, thereby sharpening the separation between the two classes.
ENN vs. Other Under-Sampling Methods
A feature-level comparison of Edited Nearest Neighbors against other common under-sampling and data cleaning techniques for imbalanced classification.
| Feature | Edited Nearest Neighbors | Tomek Links | NearMiss | Random Undersampling |
|---|---|---|---|---|
Selection Strategy | Removes majority instances misclassified by k-NN | Removes majority instances in minimally distanced opposite-class pairs | Selects majority instances closest to minority class | Randomly removes majority instances |
Preserves Decision Boundary | ||||
Removes Noisy Instances | ||||
Removes Redundant Instances | ||||
Computational Complexity | O(n^2) per iteration | O(n^2) | O(n * m * k) | O(n) |
Risk of Information Loss | Low | Low | Moderate | High |
Requires Hyperparameter Tuning | ||||
Suitable for Highly Overlapping Classes |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Edited Nearest Neighbors is part of a broader family of under-sampling and data cleaning techniques designed to clarify decision boundaries in imbalanced datasets. These methods remove noisy, redundant, or ambiguous instances to improve classifier performance.
Tomek Links
A data cleaning method that identifies pairs of minimally distanced nearest neighbors of opposite classes. The majority class instance in the pair is removed to reduce class overlap and create a cleaner separation. Tomek Links are often applied after ENN as a final boundary refinement step, eliminating borderline examples that cause ambiguity.
Neighborhood Cleaning Rule
An extension of ENN that applies a two-sided cleaning process. First, it uses the Edited Nearest Neighbors rule to remove majority class examples misclassified by their three nearest neighbors. Then, it removes minority class examples that are also misclassified by three nearest neighbors, cleaning both classes of noisy instances.
One-Sided Selection
A combined under-sampling strategy that first removes redundant majority class examples using Tomek Links, then applies Condensed Nearest Neighbors to eliminate instances far from the decision boundary. This two-stage approach retains only the majority class examples that are critical for defining the class boundary.
SMOTEENN
A hybrid resampling method that first applies SMOTE to over-sample the minority class with synthetic examples, then uses Edited Nearest Neighbors to clean noisy and overlapping examples from the resulting dataset. This combination addresses both class imbalance and class overlap simultaneously, often yielding better results than either technique alone.
Condensed Nearest Neighbors
A prototype selection algorithm that aims to find a minimal consistent subset of training data. It iteratively adds misclassified examples to a subset until all remaining instances are correctly classified by the 1-NN rule. Unlike ENN, which removes noisy examples, CNN removes redundant examples far from the boundary to reduce dataset size.
NearMiss
A family of under-sampling algorithms that selects majority class examples based on their average distance to the nearest minority class instances. NearMiss-1 keeps majority examples with the smallest average distance to three closest minority examples, preserving those near the decision boundary. NearMiss-2 selects those with the smallest average distance to three farthest minority examples.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us