skorch-dev / skorch

A scikit-learn compatible neural network library that wraps PyTorch
BSD 3-Clause "New" or "Revised" License
5.69k stars 384 forks source link

Fix issues with sklearn 1.4 #1045

Closed BenjaminBossan closed 4 months ago

BenjaminBossan commented 4 months ago

Some skorch tests fail with sklearn v1.4. This commit fixes them:

  1. Inheritance structure of scorers seems to have changed.
  2. classes_ attribute should always be numpy array
  3. CalibratedClassifierCV only works with the output of predict_proba being float64

To fix the latter, I'm now casting the output of predict_proba to float64. However, I'm not sure if this is a good idea, as it might break existing code. I'm just adding it in for now to check if the tests pass.

Update: So the tests pass. Regarding the issue with CalibratedClassifierCV and float32, here are some suggestions:

  1. Always cast to float64 and :crossed_fingers: that nothing breaks
  2. Just keep float32 and skip the tests until the sklearn fix is released
  3. Add an argument to NeuralNet to optionally cast y_proba to float64.

Personally, I'm in favor of 2.

foster999 commented 1 month ago

Hey @BenjaminBossan, I've just run into issues 2 and 3 from here. Is there likely to be a new skorch release including these soon, or would I be best to install from master to get the fixes for now?

BenjaminBossan commented 1 month ago

@foster999 Good point, thanks. I also just tested scikit-learn 1.5.0 and this time around, there don't seem to be any regressions. Release will come very soon.

foster999 commented 1 month ago

Excellent, thanks for the quick response! Shall keep my eyes peeled for a release 🚀

BenjaminBossan commented 1 month ago

@foster999 Release is out (v1.0.0 no less)

foster999 commented 1 month ago

Thanks for the heads up @BenjaminBossan ❤️