Open
Labels
Description
Describe the workflow you want to enable
Towards #26024.
Use CalibratedClassifierCV with pytorch or tensorflow models.
This has become even more interesting use case with #31068.
Describe your proposed solution
In line with out Array API adoption path.
- Temperature scaling
- Platt scaling
- Isotonic regression
Describe alternatives you've considered, if relevant
No response
Additional context
No response
Reacted by Olivier Grisel
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
OmarManzoor commentedon Sep 4, 2025
@lucascolley I was trying this out for TemperatureScaling and within that we make use of
scipy.optimize.minimize_scalarwhich currently is not compatible with the Array API.scikit-learn/sklearn/calibration.py
Lines 1131 to 1148 in 332ab38
Do we have any alternative that we can use or should we consider adding an Array API compatible version of
minimize_scalarin the utils?lucascolley commentedon Sep 4, 2025
@mdhaber have you thought about array API support for constrained minimisation? Any opinions on where to start?
lucascolley commentedon Sep 4, 2025
gh-32107 shows the existing test-suite passing while naïvely replacing
minimize_scalarwithbracket_minimumandfind_minimum(benchmarks may be a different matter).As documented at https://scipy.github.io/devdocs/dev/api-dev/array_api_modules_tables/optimize_elementwise.html, these functions have CuPy and PyTorch support, so this may be an interesting starting point for you @OmarManzoor @lucyleeow !
I haven't investigated performance for NumPy at all, but this may at least get you by as a fallback for non-NumPy arrays, while you wait for some more ticks to materialise in https://scipy.github.io/devdocs/dev/api-dev/array_api_modules_tables/optimize.html.
virchan commentedon Sep 4, 2025
@OmarManzoor,
find_minimumandbracket_minimumsupport the Array API. I've been thinking about this as well.lucascolley commentedon Sep 4, 2025
@virchan see my recent comment :)
OmarManzoor commentedon Sep 5, 2025
@lucascolley Thank you for the details on how to use
bracket_minimumandfind_minimum.OmarManzoor commentedon Sep 5, 2025
Thank you.
lucyleeow commentedon Sep 22, 2025
@OmarManzoor are you wanting to work on this?
OmarManzoor commentedon Sep 22, 2025
@lucyleeow I have done some work and experimentation with regards to TemperatureScaling. I am looking to create a PR to share my findings.
ogrisel commentedon Oct 27, 2025
#32246 has implemented array API support for the temperature scaling method which is arguably the lowest hanging fruit of the three methods.
Adding support for the other methods might be more challenging. I haven't checked the details but, I think that:
lucascolley commentedon Oct 27, 2025
I think the answer is not yet but it should be doable.
lucyleeow commentedon Nov 1, 2025
I'll start working on this!
mdhaber commentedon Nov 1, 2025
Sorry I didn't see the ping before. Re: #31869 (comment), do you mean like nonlinear constraints in multiple dimensions? (Because technically
find_minimumis constrained minimization because it enforces bounds.)They are not intended to be fast for inexpensive user callables acting on size-1 arrays ; I didn't minimize overhead. But I've seen, say, 300x improvement on large arrays with CuPy on pretty practical examples. And actually, Albert implemented the same algorithm as
find_minimumfor inverting ufuncs inspecial, all in compiled code, and it was only twice as fast as usingfind_rooton the ufuncs (with reasonably sized NumPy arrays), so it's not terrible.lucascolley commentedon Nov 1, 2025
that's what I was referring too, yeah
mdhaber commentedon Nov 1, 2025
Oh, ok, so you had already gotten your answer. Haha well sorry I'm two months late to the party.
FEA Add Array API support for sigmoid and isotonic in CalibratedClass…
tusharjamunkar commentedon Aug 27, 2026
Hi @lorentzenchr and the scikit-learn team, I would like to contribute on issue #31869 to implement Array API standard support for CalibratedClassifierCV (covering the Platt scaling and Isotonic regression paths). Could you please assign this issue to me?
LeonxLJX commentedon Sep 1, 2026