How are class probabilities estimated from neighbor votes in KNN?

Quick Overview

A machine learning interview question on how k-nearest neighbors turns neighbor votes into class probabilities, with uniform and distance-weighted votes. It tests the probability formulas, why small k gives coarse and poorly calibrated estimates, and fixes such as smoothing and calibration.

How are class probabilities estimated from neighbor votes in KNN?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

How are class probabilities estimated from neighbor votes in KNN? ```hint Count, then normalize Start from the labels of the $k$ nearest neighbors and ask how to turn them into numbers that sum to one, then what changes when closer neighbors count more. ``` ### What a Strong Answer Covers - The uniform-vote estimate as a fraction of the $k$ neighbors, and why it approximates the local posterior - The distance-weighted version and how weights such as inverse distance change it - Why the estimates are coarse and poorly calibrated when $k$ is small - Fixes such as a larger $k$, smoothing and post-hoc calibration ### Follow-up Questions - What happens with inverse-distance weights when a query point coincides with a training point? - Why are KNN probabilities computed on the training set itself overconfident? - How does the choice of $k$ trade bias against variance in these probability estimates?

Overview: A machine learning interview question on how k-nearest neighbors turns neighbor votes into class probabilities, with uniform and distance-weighted votes. It tests the probability formulas, why small k gives coarse and poorly calibrated estimates, and fixes such as smoothing and calibration.

Nov 25, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

How are class probabilities estimated from neighbor votes in KNN?

What a Strong Answer Covers Guidance

  • The uniform-vote estimate as a fraction of the kk neighbors, and why it approximates the local posterior
  • The distance-weighted version and how weights such as inverse distance change it
  • Why the estimates are coarse and poorly calibrated when kk is small
  • Fixes such as a larger kk , smoothing and post-hoc calibration

Follow-up Questions Guidance

  • What happens with inverse-distance weights when a query point coincides with a training point?
  • Why are KNN probabilities computed on the training set itself overconfident?
  • How does the choice of kk trade bias against variance in these probability estimates?