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

[ENH] Add tqdm Progress Bar for model.predict() #876

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jgyasu
Copy link

@jgyasu jgyasu commented Jan 22, 2025

Closes #818

This PR adds a tqdm progress bar to visualise the progress during the running of model.predict() method. The progress bar is put around the loop in _compute_likelihood_params() method where distributional_components are getting processed.

  • Passes black
  • Passes pylint

Thanks :)

@jgyasu
Copy link
Author

jgyasu commented Jan 22, 2025

Should I list tqdm in pyproject.toml?

@tomicapretto
Copy link
Collaborator

Hi again @jgyasu and thanks for all the contributions!

I'm not sure it's easy to resolve #818. While what you're doing effectively adds a progress bar, it adds it at the distributional component level (i.e. parameters of a likelihood for which we have at least one predictor). That is too high level. The user will see one or two "steps" and that's it.

The real difficulty is in what happens in the .predict() method (see here

def predict(
). There are several steps that can take time (predict_common, predict_group_specific, etc.)

Another pain point, and I think it's the one that usually takes the longest, is what happens when users do model.predict(... kind="response"). After computing the draws for the response parameters (e.g. mu and sigma in gaussian models), it uses pymc.draw() which usually takes some time, especially when we pass large arrays (that happens here

output_array = pm.draw(response_dist.dist(**kwargs))
)

It's not that I want to ruin the party, but I think this one is not possible to be resolved until we change how we get predictions, which would be through the proper usage of pymc.sample_posterior_predictive(). But for that to happen, we first need to modify other internal things.

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

Successfully merging this pull request may close these issues.

Progress bar for model.predict
2 participants