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

Expose minuit instance in fit #929

Closed
alexander-held opened this issue Jul 8, 2020 · 7 comments · Fixed by #988 or #1184
Closed

Expose minuit instance in fit #929

alexander-held opened this issue Jul 8, 2020 · 7 comments · Fixed by #988 or #1184
Assignees
Labels
feat/enhancement New feature or request user request Request coming form a pyhf user

Comments

@alexander-held
Copy link
Member

alexander-held commented Jul 8, 2020

Description

A fit via pyhf.infer.mle.fit() with minuit backend currently does not offer access to the minuit instance to for further operations, e.g. access to the correlation matrix. It would be convenient to optionally return it.

Is your feature request related to a problem? Please describe.

The provided pyhf.infer.mle.fit() can only be used for studies with limited scope, as important information such as parameter correlations are inaccessible.

Describe the solution you'd like

A keyword argument to optionally return the minuit instance, similar to return_uncertainties. Alternatively, the correlation matrix might be returned directly, though the full minuit instance might be more convenient (e.g. for Minos errors).

Describe alternatives you've considered

A user wanting more detailed control over the fit could implement it separately and not go through infer to bypass this limitation. This might be a good solution to prevent supporting every last use case (and will offer more detailed control over minuit, which might be desired).

Relevant Issues and Pull Requests

#881

Additional context

none

@kratsg
Copy link
Contributor

kratsg commented Jul 8, 2020

You can't get the optimizer used via _, opt = pyhf.get_backend() ?

@alexander-held
Copy link
Member Author

That returns a pyhf.optimize.opt_minuit.minuit_optimizer, and the minuit instance is built within _make_minuit() as mm, but not saved as a member variable after minimize(). I think I cannot get the right object this way.

@matthewfeickert matthewfeickert added feat/enhancement New feature or request user request Request coming form a pyhf user labels Jul 8, 2020
@lukasheinrich
Copy link
Contributor

I thin i'd rather provide APIs for the common information (eg return_correlation or return_hessian) instead of directly exposing the underlying implementation / minuit instance.

the ctor of the minuit optimizer should be able to take on fine-grained global options

pyhf.optimize.opt_minuit.minuit_optimizer(option1 = , option2 = )

what do you think @alexander-held ?

@alexander-held
Copy link
Member Author

An API to get the available information, like return_correlation, would be very convenient. This prevents users from having to worry about writing backend-agnostic implementations (to the extent that this is possible, since not all backends provide all the information).

the ctor of the minuit optimizer should be able to take on fine-grained global options

Is this already possible now, or a goal? I have not managed so far to pass information to the Minuit instance through pyhf. I am in particular thinking of customizing things like strategy / tolerance.

@kratsg
Copy link
Contributor

kratsg commented Jul 26, 2020

As of v0.5.0, the minimize() API provides a return_result_obj which contains a minuit attribute for the underlying minuit instance.

@alexander-held
Copy link
Member Author

The updates in #951 and #988 cover most of what I can think of. The last related thing that would be convenient is support for propagating strategy / tol through to Minuit, see scikit-hep/iminuit#466. Thanks a lot for these updates!

@alexander-held
Copy link
Member Author

Given the outcome of scikit-hep/iminuit#466, I am not sure whether support for strategy / tol through pyhf.infer is possible. I ended up re-implementing the relevant functionality to get access to these settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat/enhancement New feature or request user request Request coming form a pyhf user
Projects
None yet
4 participants