Skip to content
ML Academy

Classical ML, validation, metrics, interpretation, debugging · insight-0170

Remember scikit-learn's logistic regression is penalized by default before comparing it with statistics output

Evidence type
documented fact
Difficulty
easy
Roles
Data scientist, Data analyst
Industries
banking, healthcare

Summary: situation, action, reason, boundary

  1. Situation

    Coefficients from scikit-learn's LogisticRegression differ from statsmodels or R on the same data, or are used for inference.

  2. Action

    For inference, fit an unpenalized model (penalty=None or statsmodels) with standard errors; for prediction, tune C by cross-validation on standardized features.

  3. Reason

    Penalization trades bias for variance to improve prediction; coefficients are deliberately shrunk and their default strength is arbitrary relative to your feature scales.

  4. Boundary

    Any comparison between ML and statistical fits of GLMs; regulatory or scientific reporting.

Symptom or risk

Shrunken coefficients are reported as effect estimates with no standard errors; analysts doubt one of the libraries.

Exceptions

With large samples and few features, the default penalty may change coefficients only slightly; still state it.

Trade-offs

Unpenalized fits are interpretable but can be unstable with many or collinear features.

Pitfalls

Forgetting that the default penalty interacts with unscaled features, shrinking small-unit features most.

Lessons and concepts

Claims and their sources