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

Add convenient function to access list of inference methods #791

Closed
tomicapretto opened this issue Mar 30, 2024 · 4 comments · Fixed by #795
Closed

Add convenient function to access list of inference methods #791

tomicapretto opened this issue Mar 30, 2024 · 4 comments · Fixed by #795
Assignees

Comments

@tomicapretto
Copy link
Collaborator

In #775 we got access to a great variety of samplers through bayeux. Now I realize it's not that easy to get a list of inference methods. The docstring mentions model.backend.inference_methods['bayeux'] but that means we not only need a Bambi model, but a Bambi model that has already been built.

I think we should have a convenient function to get that list in an easier way. I imagine something like:

import bambi as bmb

bmb.get_inference_methods()

that uses the existing logic to return the appropriate list of inference methods, depending on whether bayeux is installed or not.

@GStechschulte
Copy link
Collaborator

GStechschulte commented Apr 1, 2024

The reason we need a defined and built Bambi model is because with bayeux algorithms are dynamically determined at runtime.

I do think it should be simpler to obtain a list of inference methods. I can imagine defining a "dummy model" similar to here to return a list of methods without the user needing to define and build a model.

Another area of improvement I see is how the user can obtain the set of kwargs for a particular inference method. Currently this requires calling bayeux directly, e.g.

bx.Model.from_pymc(model.backend.model).mcmc.blackjax_nuts.get_kwargs()

Since different samplers have different kwargs, it should be easier for the user to know what these are.

@tomicapretto
Copy link
Collaborator Author

I agree the dummy model is the way to go. So what we need is a function similar to the one you linked, that also includes the alternatives built-in pymc, right?

@GStechschulte
Copy link
Collaborator

Yup, I believe so. I can work on it this week 😄

@GStechschulte
Copy link
Collaborator

We also need to restrict what is returned when calling get_inference_methods. Currently, model.backend.inference_methods returns all bayeux methods. However, Bambi does not implement bayeux optimize algorithms for example.

Nonetheless, if the user attempts to pass jaxopt_bfgs to fit the model, the following error will be raised

NotImplementedError: 'jaxopt_bfgs' method has not been implemented

We should be more consistent to not confuse the users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants