Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Only trust neighbours that are actually near
k-NN always finds k neighbours, even if they are far away, so it always gives an answer, even for something it has never seen anything like. Radius neighbours instead ask: “which known cases lie within distance r?” If some do, vote among them. If none do, say “I don’t know.” For fault diagnosis that answer is precious: a brand-new kind of fault should raise a flag, not be confidently mislabelled as a familiar one.
Safety-critical classifiers must know the limits of their experience. A radius-based rule gives a simple, interpretable “out of envelope” test: no similar historical case means escalate to a human. The same idea underlies density-based anomaly detection and DBSCAN clustering.
- 1. Radius neighbours uses…
- 2. When no training point is within r, it…
- 3. In the demo, k-NN classifies the new fault as…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
The training points are (0, 0) and (0.5, 0) in class 0; (0, 0.5), (3, 3) and (3.4, 3) in class 1. Use r = 1.
| Query | Neighbours within 1 | Votes | Prediction |
|---|---|---|---|
| (0.1, 0.1) | (0, 0), (0.5, 0), (0, 0.5) | 0, 0, 1 | 0 |
| (3.1, 3.0) | (3, 3), (3.4, 3) | 1, 1 | 1 |
| (10, 10) | none | — | unknown |
With r = 0.2, the query (0.1, 0.1) has only (0, 0) as a neighbour, so it is still class 0.
Regression. With targets 1, 2, 3, 10, 12, the radius-1 average at (0.1, 0.1) is (1 + 2 + 3)/3 = 2. At (10, 10) there is no estimate at all.
Density. In exercise 1, a radius of 0.5 contains 233 points in a dense cluster and just 1 in a sparse one. k-NN would instead stretch its neighbourhood until it held k points.
The steps in plain English:
- Standardise features and choose a radius r (in standardised units).
- For a query, collect every training point within r.
- If there are any, vote (classification) or average (regression), optionally weighting by distance.
- If there are none, return “unknown” and escalate.
- Tune r on validation data, balancing missed novelties against unnecessary abstentions.
- 1. Prediction at (10, 10) in the example?
- 2. Radius-1 regression estimate at (0.1, 0.1)?
- 3. The number of neighbours within r depends on…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.The method
Classification: ŷ(x) = majority label in N_r(x), the set of training points with d(x, xᵢ) ≤ r, or “outlier” if N_r(x) is empty.
Regression: f̂(x) = mean of the yᵢ in N_r(x). This is the Nadaraya–Watson estimator with a uniform (box) kernel of bandwidth r.
Choosing r:
- too small, and many legitimate queries have no neighbours, or very few (noisy votes);
- too large, and distant points vote, and novel inputs fall inside the covered region.
Heuristics: a quantile of nearest-neighbour distances in the training data (for example, the 95th percentile of each point’s k-th neighbour distance), or validation with known in- and out-of-distribution examples.
Cost. The number of neighbours is unbounded in dense regions. Use radius queries on k-d trees or ball trees (D4.43).
from sklearn.neighbors import RadiusNeighborsClassifier, RadiusNeighborsRegressor
clf = RadiusNeighborsClassifier(radius=1.0, outlier_label="unknown", weights="distance").fit(X, y)
clf.predict(X_new) # 'unknown' where no training point is within the radiusUse it when you need to abstain outside the training envelope (open-set recognition, safety monitors) or when density varies and you want neighbourhoods of fixed physical size. Prefer k-NN when every query must get an answer and density varies wildly.
- 1. Radius regression is Nadaraya–Watson with a…
- 2. scikit-learn's outlier_label sets…
- 3. A larger radius makes the classifier abstain…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory and connections
Density view. The neighbour count |N_r(x)| divided by n·vol(ball of radius r) is a kernel density estimate. “No neighbours” means a low estimated density, so radius rejection is a crude density-based novelty test (D16), with threshold “density < 1/(n·vol)”.
DBSCAN connection. DBSCAN (D8) calls a point a core point if it has at least minPts neighbours within ε. Radius neighbours with an outlier label is the supervised cousin.
The open-set trade-off. As r shrinks:
- detection of novel inputs rises;
- abstention on known inputs also rises.
This traces a curve like an ROC curve (exercise 2). Choose the operating point from the costs of a missed novel fault versus an unnecessary escalation.
Consistency. Radius regression is consistent if r → 0 and n·r^p → ∞: the neighbourhoods shrink while still holding more and more points.
Interview questions.
- When is radius better than k? When a fixed physical tolerance matters, or when you want principled abstention. k-NN neighbourhoods silently grow into empty regions.
- How do you pick r without novel examples? Use the distribution of training nearest-neighbour distances (for example, the 99th percentile), accepting about 1% abstention on known data.
- 1. 'No neighbours within r' corresponds to…
- 2. DBSCAN core points have at least minPts neighbours within…
- 3. Radius regression is consistent if…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Catching never-seen faults
History.
- Fixed-radius neighbour estimators date back to Parzen-window density estimation (Rosenblatt, 1956; Parzen, 1962).
- Fixed-radius classification with a reject option was studied by Hellman (1970) in the “nearest neighbour rule with reject option”.
- Chow (1970) characterised optimal error–reject trade-offs.
- DBSCAN (Ester et al., 1996) built density clustering on ε-neighbourhoods.
- Open-set recognition (Scheirer et al., 2013) formalised abstaining on unknown classes.
Exercise 1. The hand queries give 0, 1 and “unknown”, with neighbour counts 3, 2 and 0. A radius of 0.5 holds 233 points in the dense region but only 1 in the sparse region.
Exercise 2: open-set fault diagnosis. Setup: 3 known faults in 4-D, 600 training events; in testing, 20% of events are a new fault type; 4 repetitions.
| Method | Known-fault accuracy | Known faults abstained | Novel faults flagged |
|---|---|---|---|
| 5-NN | 0.971 | 0.000 | 0.000 |
| Radius 0.75 | 0.881 | 0.089 | 0.975 |
| Radius 1.0 | 0.949 | 0.024 | 0.928 |
| Radius 1.25 | 0.968 | 0.006 | 0.824 |
| Radius 1.5 | 0.973 | 0.002 | 0.696 |
| Radius 2.0 | 0.976 | 0.000 | 0.381 |
- k-NN never says “unknown”: every novel fault is confidently given a familiar label.
- The radius sets a clean trade-off. At r = 1.0, 93% of novel faults are flagged while only 2.4% of known faults are escalated.
- Large radii recover k-NN’s accuracy on known faults but miss most novel ones.
- In operations, pick r from the costs. A missed novel fault (wrong diagnosis, wrong recovery action) usually costs far more than an extra escalation.
Radius neighbours in AI, robotics and aerospace
- Out-of-envelope detection: flag operating states never seen in test campaigns.
- Open-set fault diagnosis: escalate unfamiliar anomalies instead of misclassifying them.
- Spatial queries: all landmarks or obstacles within a sensor range (radius search in maps).
- Density-based clustering and anomaly scoring: DBSCAN and local outlier methods (D8, D16).
References
- M. E. Hellman (1970). “The nearest neighbor classification rule with a reject option.” IEEE Transactions on Systems Science and Cybernetics 6(3).
- C. K. Chow (1970). “On optimum recognition error and reject tradeoff.” IEEE Transactions on Information Theory 16(1).
- E. Parzen (1962). “On estimation of a probability density function and mode.” Annals of Mathematical Statistics 33(3).
- M. Ester, H.-P. Kriegel, J. Sander, X. Xu (1996). “A density-based algorithm for discovering clusters in large spatial databases with noise.” KDD.
- W. J. Scheirer, A. de Rezende Rocha, A. Sapkota, T. E. Boult (2013). “Toward open set recognition.” IEEE TPAMI 35(7).