Skip to content

Methods · Machine learning · Classification and regression

Distance-Weighted k-Nearest Neighbours

Distance-weighted k-nearest neighbours predicts an observation from its k closest training rows, but gives closer neighbours a larger say: votes or values are weighted by the inverse distance, the inverse squared distance, or Dudani's linear weight that falls from one for the nearest to zero for the k-th neighbour.

거리 가중 k-최근접 이웃은 가장 가까운 학습 행 k개로 관측값을 예측하되, 더 가까운 이웃에 더 큰 비중을 줍니다. 거리의 역수, 거리 제곱의 역수, 또는 가장 가까운 이웃에서 1이고 k번째 이웃에서 0이 되는 Dudani 선형 가중치로 투표나 값을 가중합니다.

Does weighting neighbours by their distance improve nearest-neighbour predictions, and which k works best?

이웃을 거리로 가중하면 최근접 이웃 예측이 좋아질까요, 그리고 어떤 k가 가장 좋을까요?

The number of neighbours is chosen by cross-validation (or fixed), and the cross-validated accuracy or RMSE of the weighted rule is shown next to ordinary unweighted voting with the same folds, across the whole range of k.

When to use Distance-Weighted k-Nearest Neighbours

When to use something else

Assumptions and requirements

What the analysis reports

How to report it

Distance-weighted kNN ([value] weights, k = [value] chosen by [value]-fold cross-validation) reached a cross-validated accuracy of [value], against [value] for unweighted voting.

Related methods

How this method is validated

이 방법의 검증 근거

  • Independent computation. 1 reference test compares the results with scikit-learn.

    독립 계산. scikit-learn 대조 참조 시험 1건 통과.

Tolerances are relative differences (absolute differences for values near zero). R comparisons and reference tests are re-run before each release of the analysis engine.

허용오차는 상대 차이입니다(0 근처 값은 절대 차이). R 대조와 참조 시험은 분석 엔진을 배포할 때마다 다시 돌립니다.

Run Distance-Weighted k-Nearest Neighbours on Quorant

Data you need
a table (CSV or Excel) with an outcome variable and predictor (feature) columns
Price
400 credits for one analysis up to 10,000 rows (complexity level 3); larger or wider data costs more. Optional methodologist review: 1800 credits.
Checking
Compared with independent computations
Before you pay
A free pre-analysis diagnosis checks your data and gives an exact quote; nothing is deducted until you approve it.

Method ID Q71078 · Reviewed 2026-10-25