Skip to content

No coefficient inference: no standard errors, p-values or model summary for linear models #353

Closed

Description

@godofecht

From community criticism review (r/datascience 'Hot Take: Scikit-learn'; Quora/Rajesh Sampathkumar; three G2 reviews).

The recurring complaint, in the Reddit OP's words:

Heck they don't even give you a way to see a model summary, because after all RSME is king and we don't care about peons like p-values.

Rajesh Sampathkumar lists it twice in six points: "Assumptions reporting" and "Model performance reports. Statsmodels provides a nice model summary, with various scoring criteria."

Current state

grep for p_value/std_err/t_stat across lib/scikit/ finds p-values in exactly one place: model_selection.flow:1354, inside permutation_test_score. That is a permutation p-value for a whole model, not inference on coefficients.

LinearRegression and LogisticRegression expose weights and bias and nothing else. There is no residual standard error, no coefficient covariance, no confidence interval, no summary.

Scope note

This one is genuinely contested in the sources and should be decided rather than assumed. Against adding it, from the same Reddit thread:

Machine learning is not statistics, if you want to do statistics use statsmodels

and u/111llI0__-__0Ill111: "I take less issue with sklearn not reporting p-values because most people doing statistical inference that way are also not doing it right on observational data and this guards against misinterpretation."

The narrow version worth doing regardless of that argument: for OLS the coefficient covariance is a by-product of the QR solve already implemented at linear.flow:149, so standard errors are nearly free. Whether to go further into p-values and a printed summary is a scope call.

Activity

  1. godofecht commented on Aug 19, 2026

    @godofecht
    OwnerAuthor

    Note from #357 / PR #443: the Newton solver added there builds the Hessian explicitly on every iteration,

    H = (1/m) X^T W X + alpha * diag([1..1, 0]),   W = diag(p * (1 - p))
    

    which is the observed Fisher information for the fit. Its inverse divided by m is the coefficient covariance matrix, so the standard errors this issue asks for are one matrix inverse away from a fit that has already paid for the hard part. lin357_newton_fit in lib/scikit/linear.flow holds it in f64 in a d x d buffer (d = n_features + 1, intercept last) at the point it converges, and _solve_f64 in the same file already does the f64 elimination an inverse would need.

    Two things to decide when this is implemented, neither of them settled here: where the matrix lives after the fit (the buffer is freed today, so it needs an owner and a free path), and whether the unpenalized case is the only one where the covariance interpretation is honest, since the alpha term shifts it away from the maximum likelihood covariance.

    PR #443 deliberately does not expose it and does not implement this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions