Skip to content
Machine Learning

Is standardization of features required before training a logistic regression?

No — rescaling a feature just rescales its coefficient, so the predictions are unchanged. It still matters in practice: gradient descent converges far faster when features share a scale, and any L1 or L2 penalty is scale-dependent, so unscaled features get penalised unevenly.

datasciencetrivia.com

Card 1 of 259. Answer: No — rescaling a feature just rescales its coefficient, so the predictions are unchanged. It still matters in practice: gradient descent converges far faster when features share a scale, and any L1 or L2 penalty is scale-dependent, so unscaled features get penalised unevenly.

Created by santiviquez

About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.

The longer answer

No, not for plain, unregularized logistic regression. Standardization rescales a feature to mean 0 and standard deviation 1, z = (x − μ) / σ. The model sees features only through the score w·x + b, so rescaling a feature rescales its coefficient by the opposite factor and the predicted probabilities do not change.

Example: an income coefficient of 0.00002 per dollar becomes 0.02 per thousand dollars, and w·x is identical. Standardizing makes the coefficient w·σ; the intercept absorbs w·μ. A penalty changes this: an L2 penalty λ Σ wᵢ² barely touches the tiny coefficient of a feature in dollars but shrinks one on a 0 to 1 scale hard, so units, not signal, decide what gets shrunk. scikit-learn's LogisticRegression applies an L2 penalty by default (C = 1.0), so there scaling does change the model.

Unscaled features also slow gradient-based solvers. A typical follow-up asks which models need scaling: KNN, SVMs, PCA, k-means and penalized models do; trees do not. Fit the scaler on training data only.

All questions