Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
8 changes: 8 additions & 0 deletions doc/whats_new/v1.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ Changelog
:class:`scipy.sparse.sparray` subclasses.
:pr:`27301` by :user:`Lohit SundaramahaLingam <lohitslohit>`.

:mod:`sklearn.linear_model`
...........................

- |Enhancement| Solver `"newton-cg"` in :class:`LogisticRegression` and
:class:`LogisticRegressionCV` uses a little less memory. The effect is proportional
to the number of coefficients (`n_features * n_classes`).
:pr:`27417` by :user:`Christian Lorentzen <lorentzenchr>`.

:mod:`sklearn.metrics`
......................

Expand Down
8 changes: 4 additions & 4 deletions sklearn/utils/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _cg(fhess_p, fgrad, maxiter, tol):
Estimated solution.
"""
xsupi = np.zeros(len(fgrad), dtype=fgrad.dtype)
ri = fgrad
ri = np.copy(fgrad)
psupi = -ri
i = 0
dri0 = np.dot(ri, ri)
Expand All @@ -100,7 +100,7 @@ def _cg(fhess_p, fgrad, maxiter, tol):
break
alphai = dri0 / curv
xsupi += alphai * psupi
ri = ri + alphai * Ap
ri += alphai * Ap
dri1 = np.dot(ri, ri)
betai = dri1 / dri0
psupi = -ri + betai * psupi
Expand Down Expand Up @@ -168,7 +168,7 @@ def _newton_cg(
Estimated minimum.
"""
x0 = np.asarray(x0).flatten()
xk = x0
xk = np.copy(x0)
k = 0

if line_search:
Expand Down Expand Up @@ -204,7 +204,7 @@ def _newton_cg(
warnings.warn("Line Search failed")
break

xk = xk + alphak * xsupi # upcast if necessary
xk += alphak * xsupi # upcast if necessary
k += 1

if warn and k >= maxiter:
Expand Down