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
- Local similarity drives the outcome and the decision boundary is irregular.
- Plain kNN is sensitive to the choice of k.
- Features are numeric and the data set is moderate in size.
When to use something else
- You want the standard unweighted rule with a full model report: use k-Nearest Neighbours
- There are many irrelevant features: use Random Forest
- You need coefficients to interpret: use Binary Logistic Regression
Assumptions and requirements
- Numeric features (z-scored within each training fold)
- Euclidean distance is meaningful
- Rows independent
What the analysis reports
- Selected k and cross-validated performance
- Comparison with unweighted voting
- Performance across k
- Line plot of CV performance by k
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
- k-Nearest Neighbours
- Random Forest
- Edited Nearest Neighbours Undersampling
- Extreme Learning Machine
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.