Notes

Radius Neighbors

Imagine you’re trying to make a prediction by asking “What do the most similar past cases say?” Radius Neighbors is a k-NN-style approach that answers that question using a distance cutoff instead of a fixed number of neighbors.

What it is and how it predicts
In Radius Neighbors, you choose a distance threshold (the radius). For a new point, the model finds all training samples within that radius under a chosen distance metric (commonly Euclidean). Then it aggregates their labels:

  • Classification: predict the class by majority vote (often with distance weighting, so closer points count more).
  • Regression: predict by averaging target values (again, optionally weighted by distance).

If no points fall inside the radius, the model needs a fallback (for example, raising an error, using a default class, or expanding the radius depending on the implementation).

Why radius-based neighbors matter
A fixed k forces the model to always consult the same number of neighbors—even in sparse regions where those neighbors might be far away and not truly “similar.” A radius rule instead enforces a notion of locality: predictions are based only on genuinely nearby examples. The trade-off is that the number of neighbors becomes variable, which can make predictions unstable in very sparse areas and sensitive to feature scaling.

Practical examples and tooling
Radius neighbors is useful when “close enough” has real meaning, such as:

  • Fraud detection: compare a transaction only to past transactions within a tight similarity radius.
  • House price prediction: average prices of homes within a radius in feature space (size, location encodings, age).
  • Disease risk scoring: rely on patients with very similar measurements, not just the nearest few.

In scikit-learn you’ll see this as RadiusNeighborsClassifier and RadiusNeighborsRegressor; getting feature scaling right (e.g., with StandardScaler) is crucial because distances drive everything.

Radius Neighbors is a k-NN variant that predicts a label or value using all training samples within a fixed distance (radius) of a query point, rather than a fixed number of neighbors. If no points fall inside the radius, the model cannot produce a standard neighbor-based prediction without a fallback rule. It matters because the radius controls locality and robustness to varying data density, strongly affecting accuracy and coverage.

Imagine you’re asking for restaurant advice, but you only trust people who live within a 10-minute walk of you. Anyone farther away doesn’t count, even if they have strong opinions. That’s the basic idea behind Radius Neighbors.

In supervised learning, Radius Neighbors is a way to make a prediction by looking only at training examples that fall within a chosen “distance” (a similarity range) of the new item you’re trying to label or estimate. For spam detection, it might compare an email only to very similar past emails; for house prices, it might use only truly comparable homes nearby. If nothing falls inside the radius, the model may have to abstain or fall back to a default.