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

Evaluation notebooks break when run #16

Open
singhish opened this issue Feb 18, 2021 · 4 comments
Open

Evaluation notebooks break when run #16

singhish opened this issue Feb 18, 2021 · 4 comments

Comments

@singhish
Copy link

singhish commented Feb 18, 2021

This is a recurring issue for each evaluation notebook. When the line

tradeoff_df["quality"] = tradeoff_df.role.apply(lambda r: r2q_map[r])

is run, execution fails with the following error:

KeyError                                  Traceback (most recent call last)
<ipython-input-23-21c779f8c074> in <module>
      1 # Make a number so that can get the plots to come out in order
----> 2 tradeoff_df["quality"] = tradeoff_df.role.apply(lambda r: r2q_map[r])
      3 tradeoff_df["count_diff"] = tradeoff_df[["count"]] - 1

~/miniconda3/envs/emissioneval/lib/python3.8/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
   3846             else:
   3847                 values = self.astype(object).values
-> 3848                 mapped = lib.map_infer(values, f, convert=convert_dtype)
   3849 
   3850         if len(mapped) and isinstance(mapped[0], Series):

pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()

<ipython-input-23-21c779f8c074> in <lambda>(r)
      1 # Make a number so that can get the plots to come out in order
----> 2 tradeoff_df["quality"] = tradeoff_df.role.apply(lambda r: r2q_map[r])
      3 tradeoff_df["count_diff"] = tradeoff_df[["count"]] - 1

KeyError: 'MAMFDC'

The error is the exact same across all evaluation notebooks except for Evaluate_power_vs_trip_start_end_analysed_master.

@shankari
Copy link
Contributor

shankari commented Feb 23, 2021

As we discussed in person, the most recent version of the notebooks was lost when I ran git checkout HEAD in the root directory by mistake. Fortunately, I do have the checkpoint files, and some files that were never actually checked in, to provide a backup. For each of the evaluation files, we need to compare the main file with the checkpointed file and resolve the differences.

More details in #12

@shankari
Copy link
Contributor

Grepped through all notebooks and the r2qmap is consistently the same.

$ grep r2q_map new_versions/*.ipynb | grep MAMFDC | wc -l
       0

I guess there might have been a version in which I added MAMFDC, but if so, it is lost to the bad checkout.
It could also be that I collected MAMFDC results primarily after the notebooks were complete.

Ah, checking my thesis, I don't have any MAMFDC results, so I presumably collected that data only after the bulk of the analysis was complete. So the fix is trivial.

@shankari
Copy link
Contributor

shankari commented Feb 24, 2021

The fix for this is

-    "r2q_map = {\"power_control\": 0, \"HAMFDC\": 1, \"MAHFDC\": 2, \"HAHFDC\": 3, \"accuracy_control\": 4}\n",
-    "q2r_map = {0: \"power\", 1: \"HAMFDC\", 2: \"MAHFDC\", 3: \"HAHFDC\", 4: \"accuracy\"}"
+    "r2q_map = {\"power_control\": 0, \"HAMFDC\": 1, \"MAHFDC\": 2, \"HAHFDC\": 3, \"MAMFDC\": 4, \"accuracy_control\": 5}\n",
+    "q2r_map = {0: \"power\", 1: \"HAMFDC\", 2: \"MAHFDC\", 3: \"HAHFDC\", 4: \"MAMFDC\", 5: \"accuracy\"}"

We should discuss the timeline for copying over the checkpoints and verifying the results. I can copy over the checkpoints first, but I am not sure I will have time to verify each of the results against the thesis.

@shankari
Copy link
Contributor

shankari commented Feb 24, 2021

I also needed to make the graphs bigger - e.g.

-    "ifig, ax_array = plt.subplots(nrows=2,ncols=3,figsize=(9,6), sharex=False, sharey=True)\n",
+    "ifig, ax_array = plt.subplots(nrows=2,ncols=3,figsize=(16,6), sharex=False, sharey=True)\n",

to accommodate the new MAMFDC entry

-    "ifig, ax_array = plt.subplots(nrows=4,ncols=3,figsize=(10,10), sharex=False, sharey=True)\n",
+    "ifig, ax_array = plt.subplots(nrows=4,ncols=3,figsize=(16,10), sharex=False, sharey=True)\n",

But that is a purely cosmetic fix. The notebook will run through without any errors even without these fixes.

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

No branches or pull requests

2 participants