-
-
Notifications
You must be signed in to change notification settings - Fork 6
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 plot_bf #116
base: main
Are you sure you want to change the base?
Add plot_bf #116
Conversation
Sir I had done some changes in multiple files for preventing the ruff errors except init file because they are causing conflicts and these changes do not effect the functionality of the whole codebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, avoid mixing two separate issues in a single PR. Ideally, you should do one to add Bayes_factor and another for fixing ruff or whatever.
src/arviz_plots/plots/bfplot.py
Outdated
@@ -0,0 +1,120 @@ | |||
import logging | |||
from arviz.plots.plot_utils import get_plotting_function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can not use ArviZ. We final goal of the refactoring is that the ArviZ package you are importing will not exist anymore.
The rest of the implementation is not how plots are implemented in Arviz-plots. Please familiarize yourself with the library before adding more changes. See how other plots are implemented, like plot_energy or plot_psense_dist
src/arviz_plots/plots/bfplot.py
Outdated
try: | ||
bf, p_at_ref_val = bayes_factor.bayes_factor( | ||
idata, var_name, prior=prior, ref_val=ref_val, return_ref_vals=True | ||
) | ||
except AttributeError as e: | ||
_log.error("Error: %s", e) | ||
raise AttributeError("Bayes factor function not found in arviz.stats.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do this, the function should be available if all packages are properly installed
Also, try to avoid writing very long messages, a lot of text makes it difficult to parse what is useful and what is just blah, blah, blah. Adding information is ok, but try to add only the most relevant information. Adding visuals is a good idea as this is a plotting library. If needed you can add more than one plot, to showcase the effect of different arguments. |
Sir, is it okay that I have added the |
No, you don't need that function. Only use functions from arviz-base, arviz-stats and arviz-plots. The approaches in the old arviz and arviz-plots are completely different, don't try to follow the code in the old one. Instead, think in terms of the elements you need to add. Essentially the minimum elements to get a bayes_factor plot are two distributions and a reference line. Check similar plots like |
@PiyushPanwarFST are you still working on this? |
Sir yes I am working on it and its about to be completed, but I stuck somewhere in dataarray or dataset in bayes_factor |
ok, just checking. |
@aloctavodia I created a new file called bfplot in ArviZ-Plots to add the plotting functionality for Bayes Factor. While calling the bayes_factor function from arviz-stats for computation, I needed to extract the posterior and prior groups, but the prior group is not available in ArviZ-Plots. Even though I loaded the data by adding a new file in inference_diagnostics using load_arviz_data("centered_eight"), the only groups I can see are: Can you please guide me how to solve this issue ? |
Try to write short comments, this could have been "The centered_eight InferenceData does not have a prior group, where I can find an Inference Data with one". Not sure what you are doing but ('/',
'/posterior',
'/posterior_predictive',
'/log_likelihood',
'/sample_stats',
'/prior',
'/prior_predictive',
'/observed_data',
'/constant_data') |
@aloctavodia I have managed to plot the Bayes Factor (BF) for the prior and posterior , but a few tasks are still pending. I wanted to share my progress and get your feedback. ![]() Still figuring out:
3. Noob question: How can I assign different colors for prior and posterior? |
Please add a commit and discuss concrete code |
6e7499f
to
4f9be34
Compare
Add function to plot Bayes Factor approximated as the Savage-Dickey density ratio algorithm
Bayes Factor Plotted graph
ADD figure once you implement the function in arviz_plots, instead of importing it from ArviZ