8000 ENH Optimize dot product order for LogisticRegression for dense matrices by jjerphan · Pull Request #19571 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
8000

ENH Optimize dot product order for LogisticRegression for dense matrices #19571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/whats_new/v1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ Changelog
:mod:`sklearn.linear_model`
...........................

- |Efficiency| The implementation of :class:`linear_model.LogisticRegression`
has been optimised for dense matrices when using `solver='newton-cg'` and
`multi_class!='multinomial'`.
:pr:`19571` by :user:`Julien Jerphanion <jjerphan>`.

- |Enhancement| Validate user-supplied gram matrix passed to linear models
via the `precompute` argument. :pr:`19004` by :user:`Adam Midvidy <amidvidy>`.

Expand Down
5 changes: 4 additions & 1 deletion sklearn/linear_model/_logistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ def _logistic_grad_hess(w, X, y, alpha, sample_weight=None):

def Hs(s):
ret = np.empty_like(s)
ret[:n_features] = X.T.dot(dX.dot(s[:n_features]))
if sparse.issparse(X):
ret[:n_features] = X.T.dot(dX.dot(s[:n_features]))
else:
ret[:n_features] = np.linalg.multi_dot([X.T, dX, s[:n_features]])
ret[:n_features] += alpha * s[:n_features]

# For the fit intercept case.
Expand Down
0