Az.plot_compare returning KeyError: 0 (from Statistical Rethinking lec 7)

Hi, i’m following the Statistical Rethinking textbook with the PYMC code examples [here]

I’m following the code example (output 17) and needed to produce the az.compare_plot. I ended up with a KeyError: 0 after running and obtained the following plot which is not the same as the notebook:

samples_dict = {1: first_sample, 2: second_sample, 3: third_sample, 4: fourth_sample}
compare_df = az.compare(samples_dict, scale=“deviance”, ic=“waic”)
compare_df
az.plot_compare(compare_df)

rank elpd_waic p_waic elpd_diff weight se dse warning scale
2 0 85.855459 5.405649 0.000000 0.588597 18.897129 0.000000 True deviance
3 1 85.948867 5.572997 0.093408 0.411403 17.488824 1.793653 True deviance
1 2 86.906720 4.735193 1.051261 0.000000 17.724246 2.073266 True deviance

image

I’m guessing the version may be the issue as the notebook uses pymc v3 and an older arviz version.

Version i’m using:

pymc: 5.0.1
arviz: 0.14.0

Appreciate help on this, thanks!

Does it also happen with newer arviz versions? I think that was a bug in old arviz versions