Why does KNN require feature scaling?

Quick Overview

Asks why k-nearest neighbors needs features on comparable scales before computing distances. Tests whether you can show how a large-range feature dominates Euclidean distance, choose a scaling method, and fit the scaler without leaking test data.

Why does KNN require feature scaling?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

Why does KNN require feature scaling? ```hint Compare the terms Write the Euclidean distance between two people described by age in years and income in dollars, and compare the size of the two terms under the square root. ``` ### What a Strong Answer Covers - How KNN uses distance and why its predictions depend on the units of each feature - A concrete case where one feature dominates the distance - Why KNN cannot compensate for scale the way a model with learned weights can - The common scaling choices and when each one fits - Fitting the scaler on training data only, and the limits of equal scaling ### Follow-up Questions - When would you choose min-max scaling over standardization for KNN, and when is a robust scaler better? - Which models do not need feature scaling, and why? - How would you handle a mix of numeric and one-hot encoded categorical features in KNN? - How does Mahalanobis distance relate to feature scaling?

Overview: Asks why k-nearest neighbors needs features on comparable scales before computing distances. Tests whether you can show how a large-range feature dominates Euclidean distance, choose a scaling method, and fit the scaler without leaking test data.

General logo
General
Nov 25, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

Why does KNN require feature scaling?

What a Strong Answer Covers Guidance

  • How KNN uses distance and why its predictions depend on the units of each feature
  • A concrete case where one feature dominates the distance
  • Why KNN cannot compensate for scale the way a model with learned weights can
  • The common scaling choices and when each one fits
  • Fitting the scaler on training data only, and the limits of equal scaling

Follow-up Questions Guidance

  • When would you choose min-max scaling over standardization for KNN, and when is a robust scaler better?
  • Which models do not need feature scaling, and why?
  • How would you handle a mix of numeric and one-hot encoded categorical features in KNN?
  • How does Mahalanobis distance relate to feature scaling?