Feature Scaling interview question

Preprocessing & Feature EngineeringFeature Scalingeasy

Your features include age (years), income (TRY) and num_logins (count), on very different scales. For which group of models is feature scaling generally required to get sensible results?

  1. ARandom forest, gradient boosting and a single decision tree, because their split thresholds are compared across features, so a large-scale feature like income would win every split.
  2. BKNN, SVM with an RBF kernel, PCA, k-means and L1/L2-regularized linear models, because distances, variances or penalties treat all the features as if they shared one scale.
  3. CGaussian Naive Bayes, decision trees and unregularized OLS, because their probability or coefficient estimates are computed in each feature's units and become unstable unscaled.
  4. DOnly neural networks, because gradient descent is the single algorithm sensitive to feature scale, while every other model family estimates its parameters in closed form.
Show the answer and explanation

Correct answer: B, KNN, SVM with an RBF kernel, PCA, k-means and L1/L2-regularized linear models, because distances, variances or penalties treat all the features as if they shared one scale.

Explanation Feature Scaling

Scaling matters whenever an algorithm compares features on a common scale:

ModelNeeds scaling?Why
KNN, k-means, SVM (RBF)yesEuclidean distances are dominated by large-scale features
PCAyesit maximises variance, so large-unit features dominate the components
Ridge, Lasso, Elastic Net, regularized logistic regressionyesthe penalty on β depends on the units of x
Neural networks, SGD-based modelsstrongly recommendedgradient descent converges much faster on similar scales
Plain OLSnot for predictionscoefficients simply rescale; scaling only aids interpretation and numerics
Decision trees, random forest, gradient boostingnoeach split thresholds one feature; only the order matters
Gaussian Naive Bayesnoeach feature gets its own mean and variance

Why the distractors fail: tree splits are evaluated within each feature ("income < 52,000?") and compared by impurity reduction, which does not depend on units. Gaussian Naive Bayes and plain OLS give the same predictions with or without scaling. Gradient descent is not the only scale-sensitive method: distances, variance maximisation and penalties are too.

In practice, put the scaler inside a scikit-learn Pipeline (or a ColumnTransformer for the numeric columns), so it is fitted on training folds only and applied identically at inference.

Interview tip: the crisp version is "distances, variances, penalties and gradients care about scale; trees do not". Mention that one-hot columns are usually left unscaled.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Preprocessing & Feature Engineering questions

  1. A gradient-boosted house-price model for Istanbul uses raw latitude and longitude as features. Prices are highest around a few prime districts and along the…
  2. How do MCAR, MAR and MNAR differ in what the probability of a value being missing depends on?
  3. What does one-hot encoding do to a categorical feature such as color with the values red, green and blue?
  4. In model training and evaluation, what does the term data leakage mean?
  5. What is a main reason to perform feature selection before training a model?