scikit-learn-contrib / MAPIE

A scikit-learn-compatible module to estimate prediction intervals and control risks based on conformal predictions.
https://mapie.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
1.3k stars 111 forks source link

ModuleNotFoundError: No module named 'mapie.conformity_scores.residual_conformity_scores' #511

Closed gaspardc-met closed 2 months ago

gaspardc-met commented 2 months ago

Hello MAPIE team Been happily using MAPIE for a while now. Filling this because I'm not sure if the regression is intended from the 0.9.0 release or not.

Describe the bug Failing to load previously trained MAPIE models

ModuleNotFoundError: No module named 'mapie.conformity_scores.residual_conformity_scores'

To Reproduce

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

thibaultcordier commented 2 months ago

Hi @gaspardc-met, thanks for your message and glad to hear you've been using MAPIE for a while.

Explanation of the bug

This bug is a direct consequence of the renaming of certain files (the mapie/conformity_scores/residual_conformity_scores.py file no longer exists, but the ResidualNormalisedScore class still exists and can be accessed from the mapie.conformity_scores module).

Suggested solution

At this stage, you can resolve this bug simply by updating the new path to the class, directly in the conformity_scores module, like this:

from mapie.conformity_scores import ResidualNormalisedScore

Conclusion

Even with the update to MAPIE, you can still access all the existing functions and classes. Their access path has just changed (surely we should have left the previous access path still operational for the time of the update).

To fully satisfy your problem of downloading an old model that you previously saved under MAPIE < 0.9.0, we're going to have to make a patch in the next few days.

Don't hesitate to let me know if this solution solves your problem.

gaspardc-met commented 2 months ago

Thank you for the feedback @thibaultcordier

To be honest the models are in production so for now I just pinned MAPIE to <0.9.0 to avoid retraining them. I will watch out for the patch and the next releases to upgrade 👍

vincentblot28 commented 2 months ago

Hello @gaspardc-met, we have just merged the PR which fixes your issue and released a new version of mapie (0.9.1) on pypi. The conda version should be available in one our two days ! We hope that this fix will solve your problems !

vincentblot28 commented 2 months ago

Mapie version 0.9.1 is now also available on conda !

gaspardc-met commented 1 month ago

Hi @vincentblot28 ,

Thank you for the patch and the heads-up. I have upgraded MAPIE to 0.9.1, and it works without updating the models.

Best regards