Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter optimize_beta is not working #588

Open
Valentin-Laurent opened this issue Jan 7, 2025 · 0 comments
Open

Parameter optimize_beta is not working #588

Valentin-Laurent opened this issue Jan 7, 2025 · 0 comments
Labels
Contributors welcome 👋🏻 Especially relevant issue/PR for contributors to work on. Discussion in progress Discussion ongoing between the Mapie team and the author. Other or internal If no other grey tag is relevant or if issue from the MAPIE team

Comments

@Valentin-Laurent
Copy link
Collaborator

Valentin-Laurent commented Jan 7, 2025

After investigating issue #484, I realized our implementation of the optimize_beta option is incorrect, and has been from its introduction in MAPIE v0.4. See also issue #583.

Code to fix:

  • In function mapie.conformity_scores.regression.BaseRegressionScore.get_bounds (the only place where beta optimization is performed), we pass a reshaped version of conformity scores to _beta_optimize, and we probably should not.
        if optimize_beta:
            beta_np = self._beta_optimize(
                alpha_np,
                conformity_scores.reshape(1, -1),
                conformity_scores.reshape(1, -1),
            )
  • The implementation of _beta_optimize seems OK-ish (see below). However, we get conformity_scores.reshape(1, -1) for parameters lower_bounds and upper_bounds, and the reshape always produces arrays of shape (1, n), so the value of len(lower_bounds) is always 1.
  • In _beta_optimize, there may be an issue with the type of _alpha in the enumerate.
  • In _beta_optimize, we distinguish lower_bounds and upper_bounds even though this value is the same, so it could be simplified.

After fixing this, we should:

  • Implement tests to make sure optimize_beta works as expected
  • Verify example notebooks that are using this feature (are the results still consistent?)

The MAPIE core team is currently in discussion regarding the priority of this fix VS other ongoing developments. Contributions are welcome :)

Note: may be helpful: when using optimize_beta with a list of alphas, the prediction intervals shape is currently incorrect.

@Valentin-Laurent Valentin-Laurent added Bug Discussion in progress Discussion ongoing between the Mapie team and the author. Other or internal If no other grey tag is relevant or if issue from the MAPIE team Contributors welcome 👋🏻 Especially relevant issue/PR for contributors to work on. labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contributors welcome 👋🏻 Especially relevant issue/PR for contributors to work on. Discussion in progress Discussion ongoing between the Mapie team and the author. Other or internal If no other grey tag is relevant or if issue from the MAPIE team
Projects
None yet
Development

No branches or pull requests

1 participant