Notes

Edited Nearest Neighbors (ENN)

When your training data has messy borders between classes—because of noise, mislabeled points, or overlapping groups—simple models can get “pulled” in the wrong direction. Edited Nearest Neighbors (ENN) is a practical way to clean those borders by removing examples that don’t agree with their local neighborhood.

What ENN does (mechanism)

ENN is an under-sampling and data cleaning method built on the same idea as k-nearest neighbors. For each training example, ENN looks at its k nearest neighbors (commonly k=3) and checks whether the example’s label matches the majority vote of those neighbors. If it disagrees, ENN removes that example from the training set. Intuitively, ENN keeps points that sit in a consistent region of their class and deletes points that look like local “contradictions” (noise, outliers, or borderline cases).

Why it matters in supervised learning

In imbalanced classification (fraud detection, rare disease diagnosis), the majority class can contain many borderline points that crowd the decision boundary. ENN helps by:

  • Reducing class overlap and sharpening the boundary.
  • Removing noisy/mislabeled samples that degrade generalization.
  • Improving downstream learners like LogisticRegression, SVM, or tree ensembles by giving them a cleaner training signal.

If you ignore this and train directly, models can overfit noise or learn a boundary that sacrifices minority-class recall.

Practical example and tooling

In credit-card fraud detection, legitimate transactions (majority class) include unusual purchases that resemble fraud. ENN can remove those locally inconsistent “legit” points, making it easier for a classifier to separate fraud from normal behavior. In Python, ENN is commonly used via imbalanced-learn:

from imblearn.under_sampling import EditedNearestNeighbours
enn = EditedNearestNeighbours(n_neighbors=3)
X_res, y_res = enn.fit_resample(X, y)

Edited Nearest Neighbors (ENN) is an instance-selection under-sampling method that cleans a labeled training set by removing examples whose class label disagrees with the majority label of their k-nearest neighbors. It primarily deletes noisy points and ambiguous border cases, typically from the majority class, to sharpen class boundaries. ENN matters because it reduces overlap and label noise, improving downstream classifier performance and robustness on imbalanced datasets.

Imagine you’re making a neighborhood watch list, but a few entries are clearly wrong—like a “safe” house surrounded by reported break-ins, or a “risky” house in a very quiet area. You’d probably remove those confusing entries so the list better reflects reality.

Edited Nearest Neighbors (ENN) does something similar for AI training data. It looks for examples that don’t “fit in” with the examples most like them nearby, and removes them. This can clean up noisy or misleading data and can also reduce the dominance of an overrepresented class, helping a model make fairer, more reliable decisions—like spotting fraud or detecting rare diseases.