Why should features be standardized before applying an L1 or L2 penalty?

Quick Overview

Asks why features should be standardized before fitting a model with an L1 or L2 penalty. Tests how feature units affect coefficient size, how ridge and lasso penalties treat each feature, and how to scale data without leakage.

Why should features be standardized before applying an L1 or L2 penalty?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

Why should features be standardized before applying an L1 or L2 penalty? ```hint Change the units Take one feature and switch its units, say from kilometers to meters. Follow what happens to its fitted coefficient, and then to the penalty charged on that coefficient. ``` ### What a Strong Answer Covers - How a feature's units determine the size of its coefficient - Why unpenalized least squares is unaffected by rescaling while a penalized fit is not - Which features end up over-penalized or under-penalized, and how that changes which features L1 keeps - What standardization does to the meaning of λ, plus its effect on optimization - Practical handling: fitting the scaler on training data only, and knowing which libraries standardize for you ### Follow-up Questions - Should you standardize one-hot encoded or binary features before a lasso fit? What changes if you do? - Why is the intercept usually left unpenalized, and how does centering the features help? - After fitting on standardized features, how do you report coefficients in the original units? - Do tree-based models need standardized features? Why or why not?

Overview: Asks why features should be standardized before fitting a model with an L1 or L2 penalty. Tests how feature units affect coefficient size, how ridge and lasso penalties treat each feature, and how to scale data without leakage.

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

Why should features be standardized before applying an L1 or L2 penalty?

What a Strong Answer Covers Guidance

  • How a feature's units determine the size of its coefficient
  • Why unpenalized least squares is unaffected by rescaling while a penalized fit is not
  • Which features end up over-penalized or under-penalized, and how that changes which features L1 keeps
  • What standardization does to the meaning of λ, plus its effect on optimization
  • Practical handling: fitting the scaler on training data only, and knowing which libraries standardize for you

Follow-up Questions Guidance

  • Should you standardize one-hot encoded or binary features before a lasso fit? What changes if you do?
  • Why is the intercept usually left unpenalized, and how does centering the features help?
  • After fitting on standardized features, how do you report coefficients in the original units?
  • Do tree-based models need standardized features? Why or why not?