question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pm.compareplot gives error "KeyError: 'pwaic'" while creating axis labels

See original GitHub issue

Describe the bug Using recent update by conda I have got an unexpected error from compareplot.

To Reproduce the code

df_comp_WAIC = pm.compare(dict([(model_gamma, trace_gamma),
                                (model_weibull, trace_weibull),
                                (model_lognormal, trace_lognormal)]),ic='WAIC')
pm.compareplot(df_comp_WAIC);

shows the plot but gives an error while trying to display the axis labels

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2656             try:
-> 2657                 return self._engine.get_loc(key)
   2658             except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'pwaic'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-123-347d24b0eaad> in <module>
      2                                 (model_weibull, trace_weibull),
      3                                 (model_lognormal, trace_lognormal)]),ic='WAIC')
----> 4 pm.compareplot(df_comp_WAIC);
      5 # df_comp_WAIC

~/anaconda3/lib/python3.7/site-packages/pymc3/plots/__init__.py in compareplot(*args, **kwargs)
     81     else:
     82         args[0] = comp_df
---> 83     return az.plot_compare(*args, **kwargs)
     84 
     85 from .posteriorplot import plot_posterior_predictive_glm

~/anaconda3/lib/python3.7/site-packages/arviz/plots/compareplot.py in plot_compare(comp_df, insample_dev, plot_standard_error, plot_ic_diff, figsize, textsize, plot_kwargs, ax)
    143     if insample_dev:
    144         ax.plot(
--> 145             comp_df[information_criterion] - (2 * comp_df["p" + information_criterion]),
    146             yticks_pos[::2],
    147             color=plot_kwargs.get("color_insample_dev", "k"),

~/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in __getitem__(self, key)
   2925             if self.columns.nlevels > 1:
   2926                 return self._getitem_multilevel(key)
-> 2927             indexer = self.columns.get_loc(key)
   2928             if is_integer(indexer):
   2929                 indexer = [indexer]

~/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2657                 return self._engine.get_loc(key)
   2658             except KeyError:
-> 2659                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   2660         indexer = self.get_indexer([key], method=method, tolerance=tolerance)
   2661         if indexer.ndim > 1 or indexer.size > 1:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'pwaic'

Expected behavior I haven’t had such problem before

Additional context

Running with PyMC3 version v.3.7.rc1
Running with arviz version v.0.3.2
Running with pandas version v.0.24.2

installed by conda (python 3.7.3, macOS)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aakhmetzcommented, Jul 25, 2019

@OriolAbril Yes, I checked with ArviZ 0.4.1 today, and it worked smoothly. Thank you again

0reactions
aakhmetzcommented, Jul 25, 2019

@OriolAbril Thanks for checking and for your time! I will be waiting for the next update then

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pm.compareplot throws error - version agnostic
I was comparing two models with pm.compare and I wanted to visualize the values using pm.compare but I got an error.
Read more >
KeyError: "['PWR'] not found in axis" - Stack Overflow
Save this question. Show activity on this post. ****I tried different methods and was following the guidance from that notebook, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found