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

Patch fixes: Eliminate plot_title for Replaced mode stacked bar charts #157

Merged
merged 3 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions viz_scripts/generic_metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@
" expanded_ct_sensed_u80 = expanded_ct_sensed.loc[(expanded_ct_sensed['distance'] <= cutoff)]\n",
"\n",
" sensed_u80_quality_text = f\"{len(expanded_ct_sensed_u80)} trips ({round(len(expanded_ct_sensed_u80)/len(expanded_ct_sensed)*100)}% of all trips)\\nfrom {scaffolding.unique_users(expanded_ct_sensed_u80)} {sensed_match.group(3)}\"\n",
" labeled_u80_quality_text = f\"{len(expanded_ct_u80)} trips ({round(len(expanded_ct_u80)/len(expanded_ct)*100)}% of all labeled,\\n{round(len(expanded_ct_u80)/len(expanded_ct_sensed)*100)}% of all trips)\\nfrom {scaffolding.unique_users(expanded_ct_u80)} {sensed_match.group(3)}\" if \"Mode_confirm\" in expanded_ct.columns else \"0 labeled trips\"\n",
" inferred_u80_quality_text = f\"{len(expanded_ct_inferred_u80)} trips ({round(len(expanded_ct_inferred_u80)/len(expanded_ct_inferred)*100)}% of all inferred,\\n{round(len(expanded_ct_inferred_u80)/len(expanded_ct_sensed)*100)}% of all trips)\\nfrom {scaffolding.unique_users(expanded_ct_inferred_u80)} {sensed_match.group(3)}\" if \"Mode_confirm\" in expanded_ct_inferred.columns else \"0 inferred trips\"\n",
" labeled_u80_quality_text = f\"{len(expanded_ct_u80)} trips ({round(len(expanded_ct_u80)/len(expanded_ct)*100)}% of all labeled,\\n{round(len(expanded_ct_u80)/len(expanded_ct_sensed)*100)}% of all trips)\\nfrom {scaffolding.unique_users(expanded_ct_u80)} {sensed_match.group(3)}\" if \"mode_confirm_w_other\" in expanded_ct.columns else \"0 labeled trips\"\n",
" inferred_u80_quality_text = f\"{len(expanded_ct_inferred_u80)} trips ({round(len(expanded_ct_inferred_u80)/len(expanded_ct_inferred)*100)}% of all inferred,\\n{round(len(expanded_ct_inferred_u80)/len(expanded_ct_sensed)*100)}% of all trips)\\nfrom {scaffolding.unique_users(expanded_ct_inferred_u80)} {sensed_match.group(3)}\" if \"mode_confirm_w_other\" in expanded_ct_inferred.columns else \"0 inferred trips\"\n",
"\n",
" # Plot entries\n",
" fig, ax = plt.subplots(nrows=3, ncols=1, figsize=(15,3*2), sharex=True)\n",
Expand Down
9 changes: 3 additions & 6 deletions viz_scripts/mode_specific_metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@
" f\"Labeled `{mode_of_interest}` by user\\n\"+stacked_bar_quality_text, ax[0], text_results[0], colors_purpose, debug_df, value_to_translations_purpose)\n",
" plot_and_text_stacked_bar_chart(data_eb_inferred, lambda df: df.groupby(\"purpose_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False),\n",
" f\"Labeled and Inferred `{mode_of_interest}` by OpenPATH\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_purpose, debug_df_inferred, value_to_translations_purpose)\n",
" plot_title = plot_title_no_quality + \"\\n\" + f\"For {mode_of_interest}: \" + quality_text\n",
" set_title_and_save(fig, text_results, plot_title, file_name)\n",
" set_title_and_save(fig, text_results, plot_title_no_quality, file_name)\n",
"except (AttributeError, KeyError, pd.errors.UndefinedVariableError) as e:\n",
" plt.clf()\n",
" generate_missing_plot(plot_title_no_quality, debug_df, file_name)\n",
Expand Down Expand Up @@ -314,8 +313,7 @@
" \"Labeled by user\\n (Trip distance)\\n\"+stacked_bar_quality_text, ax[0], text_results[0], colors_replaced, debug_df, value_to_translations_replaced)\n",
" plot_and_text_stacked_bar_chart(data_eb_inferred, lambda df: df.groupby(\"replaced_mode_w_other\").agg({distance_col: 'sum'}).sort_values(by=distance_col, ascending=False), \n",
" \"Labeled and Inferred by OpenPATH\\n (Trip distance)\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_replaced, debug_df_inferred, value_to_translations_replaced)\n",
" plot_title = plot_title_no_quality\n",
" set_title_and_save(fig, text_results, plot_title, file_name)\n",
" set_title_and_save(fig, text_results, plot_title_no_quality, file_name)\n",
"except (AttributeError, KeyError, pd.errors.UndefinedVariableError) as e:\n",
" plt.clf()\n",
" generate_missing_plot(plot_title_no_quality, debug_df, file_name)\n",
Expand Down Expand Up @@ -351,8 +349,7 @@
" f\"Labeled `{mode_of_interest}` by user\\n\"+stacked_bar_quality_text, ax[0], text_results[0], colors_replaced, debug_df, value_to_translations_replaced)\n",
" plot_and_text_stacked_bar_chart(data_eb_inferred, lambda df: df.groupby(\"replaced_mode_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False), \n",
" f\"Labeled and Inferred `{mode_of_interest}` by OpenPATH\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_replaced, debug_df_inferred, value_to_translations_replaced)\n",
" plot_title = plot_title_no_quality + \"\\n\" + f\"For {mode_of_interest}: \" + quality_text\n",
" set_title_and_save(fig, text_results, plot_title, file_name)\n",
" set_title_and_save(fig, text_results, plot_title_no_quality, file_name)\n",
"except (AttributeError, KeyError, pd.errors.UndefinedVariableError) as e:\n",
" plt.clf()\n",
" generate_missing_plot(plot_title_no_quality, debug_df, file_name)\n",
Expand Down
8 changes: 4 additions & 4 deletions viz_scripts/scaffolding.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ async def load_viz_notebook_data(year, month, program, study_type, dynamic_label
"Participants_with_at_least_one_trip": unique_users(participant_ct_df),
"Participant_with_at_least_one_labeled_trip": unique_users(labeled_ct),
"Trips_with_at_least_one_label": len(labeled_ct),
"Trips_with_mode_confirm_label": trip_label_count("Mode_confirm", expanded_ct),
"Trips_with_trip_purpose_label": trip_label_count("Trip_purpose", expanded_ct)
"Trips_with_mode_confirm_label": trip_label_count("mode_confirm_w_other", expanded_ct),
"Trips_with_trip_purpose_label": trip_label_count("purpose_confirm_w_other", expanded_ct)
},
orient='index', columns=["value"])

Expand Down Expand Up @@ -254,8 +254,8 @@ async def load_viz_notebook_inferred_data(year, month, program, study_type, dyna
"Participants_with_at_least_one_trip": unique_users(participant_ct_df),
"Participant_with_at_least_one_inferred_trip": unique_users(inferred_ct),
"Trips_with_at_least_one_inferred_label": len(inferred_ct),
"Trips_with_mode_confirm_inferred_label": trip_label_count("Mode_confirm", expanded_it),
"Trips_with_trip_purpose_inferred_label": trip_label_count("Trip_purpose", expanded_it)
"Trips_with_mode_confirm_inferred_label": trip_label_count("mode_confirm_w_other", expanded_it),
"Trips_with_trip_purpose_inferred_label": trip_label_count("purpose_confirm_w_other", expanded_it)
},
orient='index', columns=["value"])

Expand Down