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

Skip to content

ENH: add array API support for specific methods in the private loss module - #34321

Merged
lorentzenchr merged 7 commits into
scikit-learn:mainfrom
OmarManzoor:loss_array_api
Jun 18, 2026
Merged

ENH: add array API support for specific methods in the private loss module#34321
lorentzenchr merged 7 commits into
scikit-learn:mainfrom
OmarManzoor:loss_array_api

Conversation

@OmarManzoor

@OmarManzoor OmarManzoor commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

What does this implement/fix? Explain your changes.

  • Adds array API support for the gradient_hessian method of:

    • HalfBinomialLossArrayAPI
    • HalfMultinomialLossArrayAPI
    • HalfPoissonLossArrayAPI
  • Adds array API support for the gradient_proba method of HalfMultinomialLossArrayAPI

AI usage disclosure

I used AI assistance for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
    • Used Antigravity with Claude Sonnet

Any other comments?

@OmarManzoor

OmarManzoor commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

CC: @lorentzenchr this might help in the implementation of array API support for newton_cg for LogisticRegression

Comment thread sklearn/_loss/loss.py Outdated

@lorentzenchr lorentzenchr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OmarManzoor Thanks for this nice PR.

Comment thread sklearn/_loss/tests/test_loss.py Outdated
Comment thread sklearn/_loss/loss.py Outdated
Comment thread sklearn/_loss/loss.py Outdated
Comment thread sklearn/_loss/loss.py Outdated
Comment thread sklearn/_loss/loss.py Outdated
Comment thread sklearn/_loss/loss.py
@OmarManzoor

OmarManzoor commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@lorentzenchr I added the _compute_gradient_hessian implementations for all three and added the main method gradient_hessian in the base ArrayAPILossMixin.

Comment thread sklearn/_loss/loss.py Outdated
Co-authored-by: Christian Lorentzen <[email protected]>
@lorentzenchr lorentzenchr added the Waiting for Second Reviewer First reviewer is done, need a second one! label Jun 18, 2026
@OmarManzoor

Copy link
Copy Markdown
Contributor Author

@lorentzenchr Can we merge this with your review 🙂 ?

@lorentzenchr

Copy link
Copy Markdown
Member

Yes I can.
FYI, I have a yet unpublishes branch that touches the linear loss (which has a funny difference between methods that lbfgs uses and methods that newton-cg uses;-). I got then stuck with the line search. We need to wait for my upstream changes in scipy 1.18 for that.

@lorentzenchr
lorentzenchr merged commit ccf7eaf into scikit-learn:main Jun 18, 2026
43 checks passed
@OmarManzoor
OmarManzoor deleted the loss_array_api branch June 18, 2026 09:19
@OmarManzoor

Copy link
Copy Markdown
Contributor Author

Thank you for the review @lorentzenchr

prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 2, 2026
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Array API No Changelog Needed Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants