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

Replacing PyMC3 plots w/ Arviz plots & sigma Param change [Part 1] #27

Merged

Conversation

CloudChaoszero
Copy link
Contributor

Description

The following is a large PR breakdown of PR #16.

Replace PyMC3 dependent plots with arviz plots in case studies & examples.

Replace parameter sd with sigma (e.g. some examples have pm.Normal(...sd=...)

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is great!

Small roadmap question, what is the plan on using return_inferencedata=True regarding examples?

Comment on lines 56 to 57
pm.traceplot(
az.plot_trace(
trace, varnames=["mu", "r"], lines={"mu": mu_r, "r": corr_r[np.triu_indices(n_var, k=1)]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am quite sure arviz does not accept varnames, it should be var_names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, correct! Thanks for that. I updated to arviz 0.11, and got this error

y:212: UserWarning: A valid var_name should be provided, found {'m'} expected from {'mu', 'r'}
  warnings.warn(
Traceback (most recent call last):
  File "LKJ_correlation.py", line 62, in <module>
    run()
  File "LKJ_correlation.py", line 56, in run
    az.plot_trace(
  File "/Users/CloudChaoszero/opt/anaconda3/envs/pymc3-dev-py38/lib/python3.8/site-packages/arviz/plots/traceplot.py", line 238, in plot_trace
    axes = plot(**trace_plot_args)
  File "/Users/CloudChaoszero/opt/anaconda3/envs/pymc3-dev-py38/lib/python3.8/site-packages/arviz/plots/backends/matplotlib/traceplot.py", line 384, in plot_trace
    for _, _, vlines in (j for j in lines if j[0] == var_name and j[1] == selection):
  File "/Users/CloudChaoszero/opt/anaconda3/envs/pymc3-dev-py38/lib/python3.8/site-packages/arviz/plots/backends/matplotlib/traceplot.py", line 384, in <genexpr>
    for _, _, vlines in (j for j in lines if j[0] == var_name and j[1] == selection):
IndexError: string index out of range

(This error looks related arviz-devs/arviz#988)

Any thoughts why this happened?

Copy link
Contributor Author

@CloudChaoszero CloudChaoszero Feb 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found out why now. It's due to the lines param.

az.plot_trace(
        trace, varnames=["mu", "r"], lines={"mu": mu_r, "r": corr_r[np.triu_indices(n_var, k=1)]}
...

I removed it to make the az.plot_trac() work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try

lines=(("mu", {}, mu_r), ("r", {}, corr_r[np.triu_indices(n_var, k=1)])) 

examples/pymc3_howto/rankdata_ordered.py Outdated Show resolved Hide resolved
examples/pymc3_howto/rankdata_ordered.py Outdated Show resolved Hide resolved
@CloudChaoszero
Copy link
Contributor Author

Small roadmap question, what is the plan on using return_inferencedata=True regarding examples?

Yeah @OriolAbril ! I was hoping to get these ~9 PRs merged into the repo, and the proceed into that.
These PRs just focus on

  • sigma param
  • Plot dependencies
    However, I am still have some delays on my side 😅

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That timeline sounds great @CloudChaoszero! Thanks!

@twiecki twiecki merged commit f51ce8c into pymc-devs:main Feb 7, 2021
@CloudChaoszero CloudChaoszero deleted the replace-pymc3-arviz-plots_part1 branch April 5, 2021 01:52
twiecki pushed a commit that referenced this pull request Jan 17, 2023
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.

4 participants