Skip to content

Commit dde5372

Browse files
committed
add stacked bar for prediction category counts
1 parent 1cd279c commit dde5372

4 files changed

Lines changed: 645 additions & 4 deletions

File tree

rt_predictions/chart_utils_for_operators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Chart and map functions for operator report.
33
"""
44

5+
import _color_palette
56
import altair as alt
67
import pandas as pd
78
from great_tables import GT
8-
from gtfs_curator_utils import _color_palette
99

1010

1111
def basic_percentiles_line_chart(

rt_predictions/operator_report.ipynb

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@
9696
" \"n_stops\", \"num_stop_times\", \"daily_arrivals\", 'n_days_schedule_and_rt'\n",
9797
"]\n",
9898
"\n",
99-
"vp_cols = ['vp_messages_per_minute', 'pct_vp_trips', 'pct_vp_routes'] #'daily_vp_trips'\n",
100-
"tu_cols =['tu_messages_per_minute', 'pct_tu_trips', 'pct_tu_routes'] #'daily_tu_trips',\n",
99+
"vp_cols = ['vp_messages_per_minute', 'pct_vp_trips', 'pct_vp_routes'] \n",
100+
"tu_cols =['tu_messages_per_minute', 'pct_tu_trips', 'pct_tu_routes']\n",
101101
"\n",
102102
"tu_prediction_cols = [\n",
103103
" \"bus_catch_likelihood\", \"pct_tu_complete_minutes\", # both are percents\n",
@@ -369,6 +369,41 @@
369369
"# maybe IQR doesn't make sense to color, it'll just be ranked by day_type"
370370
]
371371
},
372+
{
373+
"cell_type": "code",
374+
"execution_count": null,
375+
"id": "b3950f3e-2e99-4da9-bc2d-78f61ab2806b",
376+
"metadata": {},
377+
"outputs": [],
378+
"source": [
379+
"pct_category_df = prep_operator_data.reshape_prediction_category_counts_to_long(df)\n",
380+
"\n",
381+
"category_counts_stacked_bar = alt.Chart(pct_category_df).mark_bar().encode(\n",
382+
" x=alt.X(\n",
383+
" 'day_type',\n",
384+
" title = \"\", sort=[\"Weekday\", \"Saturday\", \"Sunday\"]\n",
385+
" ),\n",
386+
" y=alt.Y('pct', title=\"Percent\"),\n",
387+
" color=alt.Color(\n",
388+
" 'prediction_category:N',\n",
389+
" title=\"Prediction Category\", \n",
390+
" sort=[\"early\", \"ontime\", \"late\"],\n",
391+
" scale=alt.Scale(range=[\n",
392+
" _color_palette.get_color(\"light_cadmium_yellow\"),\n",
393+
" _color_palette.get_color(\"electric_orange\"),\n",
394+
" _color_palette.get_color(\"aquatic\")\n",
395+
" ])\n",
396+
" ),\n",
397+
" column=alt.Column(\"tu_name\", title = \"\"),\n",
398+
" tooltip=[\"tu_name\", \"day_type\", \"prediction_category\", \"pct\"]\n",
399+
").interactive().properties(\n",
400+
" title = \"Predictions by Category\",\n",
401+
" width=150, height = 200\n",
402+
")\n",
403+
"\n",
404+
"category_counts_stacked_bar"
405+
]
406+
},
372407
{
373408
"cell_type": "markdown",
374409
"id": "3033b010-f091-4a32-8df1-38dc7d2fd3af",

0 commit comments

Comments
 (0)