Repository navigation
FEA Add array API support for temperature scaling in CalibratedClassifierCV - #32246
Conversation
|
Note: Since this is a DRAFT PR for now I left the bench.py file so that we can experiment if required. |
Has this problem already been reported upstream?
I think it's fair for meta estimators to only support array API when the base estimator does (and let any exception raised by the underlying estimator bubble up otherwise).
How is that a problem? I think our cross-validation tools support array API, no? If not, we should fix that first.
Have you tried to use a profiler to understand the performance difference between scipy versions with torch/mps? Ideally, this should be reported as a performance regression upstream along with a minimal reproducer that does not involve scikit-learn. |
|
@ogrisel Also I haven't reported either of the scipy issues that I noted. But wouldn't it be better for someone else to confirm my observations as well? |
Ah ok. This should indeed be addressed in a dedicated PR then. |
|
I confirm that I observe a similar performance regression using SciPy 1.16 (vs 1.15) using the |
|
I opened a scipy issue with respect to the slower runtimes that we noted: scipy/scipy#23670 |
ogrisel
left a comment
There was a problem hiding this comment.
Here is some preliminary feedback, some of which we already discussed in over discord.
virchan
left a comment
There was a problem hiding this comment.
The Array API version _half_multinomial_loss should be okay. I did some tests to compare it with HalfMultinomialLoss in addition to running test_half_multinomal_loss, and they all passed.
Thank you for verifying |
… api support for cross_val_predict
ogrisel
left a comment
There was a problem hiding this comment.
Overall, LGTM once the following have been addressed:
|
And please re-run the CUDA tests after update. |
ogrisel
left a comment
There was a problem hiding this comment.
LGTM. Once array-apy-extra 0.9.1 is released we should not forget to revendor and simplify the isclose call.
virchan
left a comment
There was a problem hiding this comment.
LGTM! Thanks, @OmarManzoor!
Just one minor nitpick.
|
Thanks for the second review @virchan! By the way, are you still interested in working on array API support for |
|
Yes, I'm still working on |
…fierCV (scikit-learn#32246) Co-authored-by: Lucy Liu <[email protected]>
Reference Issues/PRs
Address #31869
What does this implement/fix? Explain your changes.
Notes:
find_minimumfromscipy.optimize.elementwisethat supports the array API doesn't quite work because it works with arrays and if we use arrays as inputs and outputs it breaks forarray-api-strict. If we stick with scalars it breaks at a point where an array is expected.minimize_scalarwhich we use currently simply uses scalar values within it's main computation loops, I convert the input to the array API when entering the_half_multinomial_lossfunction and converting to a float when returning from it. This has the drawback of converting back and forth between the cpu and gpu._TemperatureScalingclass on google colab and my local mac M1, the results are as follows which show they vary based on the scipy version:I noted the significant performance with scipy == 1.15.3 because I also tried running the benchmarks on a Kaggle kernel and since that supports Python 3.10 something the maximum scipy version that we can get there is 1.15.3.
Any other comments?
CC: @ogrisel @betatim @virchan @lesteve
What is your opinion? Should we support array API for this class?