e-mission / em-public-dashboard

A simple and stupid public dashboard prototype.
BSD 3-Clause "New" or "Revised" License
1 stars 23 forks source link

Changes on generic_metric and mode_specific_metrics in relation to Mo… #91

Closed iantei closed 9 months ago

iantei commented 1 year ago

…de_confirm mapping with dynamic labels.

iantei commented 10 months ago
  • I want to see an explanation of the sensed notebooks in the Lao case

I am observing some errors with sensed notebook for Lao case.

Changes:

STUDY_CONFIG=`usaid-laos-ev`
Using vail dataset.

I am getting the following errors:

Error Details

/usr/src/app/saved-notebooks/bin/generate_plots.py:30: SyntaxWarning: "is not" with a literal. Did you mean "!="? if r.status_code is not 200: About to download config from https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/configs/usaid-laos-ev.nrel-op.json Successfully downloaded config with version 1 for USAID-NREL Support for Electric Vehicle Readiness and data collection URL https://USAID-laos-EV-openpath.nrel.gov/api/ Running at 2023-11-21T00:26:03.065634+00:00 with args Namespace(plot_notebook='generic_metrics_sensed.ipynb', program='default', date=None) for range (, ) Running at 2023-11-21T00:26:03.105566+00:00 with params [Parameter('program', str, value='default'), Parameter('study_type', str, value='study'), Parameter('include_test_users', bool, value=True), Parameter('sensed_algo_prefix', str, value='cleaned')] Traceback (most recent call last): File "/usr/src/app/saved-notebooks/bin/generate_plots.py", line 84, in compute_for_date(None, None) File "/usr/src/app/saved-notebooks/bin/generate_plots.py", line 81, in compute_for_date nbclient.execute(new_nb) File "/root/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute() File "/root/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped return loop.run_until_complete(inner) File "/root/miniconda-23.1.0/envs/emission/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete return future.result() File "/root/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute await self.async_execute_cell( File "/root/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell await self._check_raise_for_error(cell, cell_index, exec_reply) File "/root/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content) nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell: ------------------ expanded_ct, file_suffix, quality_text, debug_df = scaffolding.load_viz_notebook_sensor_inference_data(year, month, program, include_test_users, sensed_algo_prefix) ------------------ ----- stdout ----- Loaded all confirmed trips of length 57407 ----- stdout ----- After filtering, found 57407 participant trips ----- stdout ----- Loaded expanded_ct with length 57407 for None ------------------ --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[3], line 1 ----> 1 expanded_ct, file_suffix, quality_text, debug_df = scaffolding.load_viz_notebook_sensor_inference_data(year, 2 month, 3 program, 4 include_test_users, 5 sensed_algo_prefix) File /usr/src/app/saved-notebooks/scaffolding.py:175, in load_viz_notebook_sensor_inference_data(year, month, program, include_test_users, sensed_algo_prefix) 173 print(f"Loaded expanded_ct with length {len(expanded_ct)} for {tq}") 174 if len(expanded_ct) > 0: --> 175 expanded_ct["primary_mode_non_other"] = participant_ct_df.cleaned_section_summary.apply(lambda md: max(md["distance"], key=md["distance"].get)) 176 expanded_ct.primary_mode_non_other.replace({"ON_FOOT": "WALKING"}, inplace=True) 177 valid_sensed_modes = ["WALKING", "BICYCLING", "IN_VEHICLE", "AIR_OR_HSR", "UNKNOWN"] File ~/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/pandas/core/series.py:4771, in Series.apply(self, func, convert_dtype, args, **kwargs) 4661 def apply( 4662 self, 4663 func: AggFuncType, (...) 4666 **kwargs, 4667 ) -> DataFrame | Series: 4668 """ 4669 Invoke function on values of Series. 4670 (...) 4769 dtype: float64 4770 """ -> 4771 return SeriesApply(self, func, convert_dtype, args, kwargs).apply() File ~/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/pandas/core/apply.py:1123, in SeriesApply.apply(self) 1120 return self.apply_str() 1122 # self.f is Callable -> 1123 return self.apply_standard() File ~/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/pandas/core/apply.py:1174, in SeriesApply.apply_standard(self) 1172 else: 1173 values = obj.astype(object)._values -> 1174 mapped = lib.map_infer( 1175 values, 1176 f, 1177 convert=self.convert_dtype, 1178 ) 1180 if len(mapped) and isinstance(mapped[0], ABCSeries): 1181 # GH#43986 Need to do list(mapped) in order to get treated as nested 1182 # See also GH#25959 regarding EA support 1183 return obj._constructor_expanddim(list(mapped), index=obj.index) File ~/miniconda-23.1.0/envs/emission/lib/python3.9/site-packages/pandas/_libs/lib.pyx:2924, in pandas._libs.lib.map_infer() File /usr/src/app/saved-notebooks/scaffolding.py:175, in load_viz_notebook_sensor_inference_data..(md) 173 print(f"Loaded expanded_ct with length {len(expanded_ct)} for {tq}") 174 if len(expanded_ct) > 0: --> 175 expanded_ct["primary_mode_non_other"] = participant_ct_df.cleaned_section_summary.apply(lambda md: max(md["distance"], key=md["distance"].get)) 176 expanded_ct.primary_mode_non_other.replace({"ON_FOOT": "WALKING"}, inplace=True) 177 valid_sensed_modes = ["WALKING", "BICYCLING", "IN_VEHICLE", "AIR_OR_HSR", "UNKNOWN"] TypeError: 'float' object is not subscriptable (emission) root@b4d4d64a5353:/usr/src/app/saved-notebooks#

Tried with the main repo, without my changes related with dynamic config. Still getting the same error.

https://github.com/e-mission/em-public-dashboard/issues/89#issuecomment-1738332926 Referring to the above Issue discussion, there are instances of NaN values in the data which is causing this issue.

The results are displayed below with some code changes on scaffolding.py to debug:

Code changes and Results

Code changes: ``` participant_ct_df = all_ct[all_ct.user_id.isin(participant_list)] if participant_ct_df.isna().values.any(): print("The DataFrame contains missing values (NaN).") else: print("The DataFrame does not contain any missing values.") print(participant_ct_df.inferred_section_summary[participant_ct_df.inferred_section_summary.isna()]) print("After filtering, found %s participant trips " % len(participant_ct_df)) ``` Results: ``` The DataFrame contains missing values (NaN). 0 NaN 1 NaN 2 NaN 3 NaN 4 NaN ... 57396 NaN 57397 NaN 57398 NaN 57399 NaN 57400 NaN Name: inferred_section_summary, Length: 57401, dtype: object After filtering, found 57407 participant trips ```

iantei commented 10 months ago

@iantei looking through my prior comments to make sure that they are all resolved, I ran into this comment.

Similarly, notebook execution for sensed notebook failed since we have some NaN values in the dataset used - as justified above.

As justified where? The sensed notebooks should not be config specific since we don't use user labels in them.

The conversation was documented in Issue section, https://github.com/e-mission/em-public-dashboard/issues/89#issuecomment-1738332926 For my case where I am using vail dataset, I am encountering issue which I have enlisted above.

shankari commented 10 months ago

Overall the charts looks identical.

Not really. I still see differences in:

  1. Trip count by purpose

I see your comment around

Note: There is no mapping for "pilot_ebike" to "E-bike". Therefore, these mapping has been transformed into "Others" in "Number of Commute Trips" and "Trip count by Purpose" charts above.

But "Trip count by Purpose" does not display modes, so a difference in the e-bike label should not make any difference. And there is no "other" in the purpose charts anyway. It does cause the large "other" in "Number of trips", so I have not flagged that.

  1. Trip count under 10 miles is comparing modes to purpose
  2. Trip miles by mode
  3. Average trip length

Also, "generic_metrics" as an example (note the e.g. before it). I would like to see at least a few metrics from the mode specific and energy/emission notebooks.

I still want to see all the outputs (e.g. generic metrics) one last time to make sure that there are no regressions

iantei commented 9 months ago
Comparison of mode specific metrics outputs:

Executed the notebook "Mode Specific Metrics" for both the STUDY_CONFIG for comparison between default mapping and dynamic config. Steps executed: A. For Default Mapping (STUDY_CONFIG=stage-program): ``` (emission) root@1d89306b8d05:/usr/src/app/saved-notebooks# PYTHONPATH=.. python bin/update_mappings.py mapping_dictionaries.ipynb (emission) root@1d89306b8d05:/usr/src/app/saved-notebooks# PYTHONPATH=.. python bin/generate_plots.py mode_specific_metrics.ipynb default /usr/src/app/saved-notebooks/bin/generate_plots.py:30: SyntaxWarning: "is not" with a literal. Did you mean "!="? if r.status_code is not 200: About to download config from https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/configs/stage-program.nrel-op.json Successfully downloaded config with version 1 for Staging environment for testing programs only and data collection URL https://openpath-stage.nrel.gov/api/ label_options is unavailable for the dynamic_config in stage-program Running at 2023-11-24T19:16:46.712768+00:00 with args Namespace(plot_notebook='mode_specific_metrics.ipynb', program='default', date=None) for range (, ) Running at 2023-11-24T19:16:46.748639+00:00 with params [Parameter('year', int), Parameter('month', int), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('dynamic_labels', dict, value={})] Running at 2023-11-24T19:17:32.189017+00:00 with params [Parameter('year', int, value=2020), Parameter('month', int, value=9), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('dynamic_labels', dict, value={})] Running at 2023-11-24T19:17:38.020350+00:00 with params [Parameter('year', int, value=2020), Parameter('month', int, value=10), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('dynamic_labels', dict, value={})] Running at 2023-11-24T19:17:43.716868+00:00 with params [Parameter('year', int, value=2020), Parameter('month', int, value=11), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('dynamic_labels', dict, value={})] Running at 2023-11-24T19:17:50.061952+00:00 with params [Parameter('year', int, value=2020), Parameter('month', int, value=12), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('dynamic_labels', dict, value={})] ``` B. For Dynamic Config (STUDY_CONFIG=dev-emulator-program): ``` (emission) root@f1a86a1f3abd:/usr/src/app/saved-notebooks# PYTHONPATH=.. python bin/update_mappings.py mapping_dictionaries.ipynb (emission) root@f1a86a1f3abd:/usr/src/app/saved-notebooks# PYTHONPATH=.. python bin/generate_plots.py mode_specific_metrics.ipynb default /usr/src/app/saved-notebooks/bin/generate_plots.py:30: SyntaxWarning: "is not" with a literal. Did you mean "!="? if r.status_code is not 200: About to download config from https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/configs/dev-emulator-program.nrel-op.json Successfully downloaded config with version 1 for Development environment (program) and data collection URL default Dynamic labels download was successful for nrel-openpath-deploy-configs: dev-emulator-program Running at 2023-11-24T18:33:55.368650+00:00 with args Namespace(plot_notebook='mode_specific_metrics.ipynb', program='default', date=None) for range (, ) Running at 2023-11-24T18:33:55.404501+00:00 with params [Parameter('year', int), Parameter('month', int), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=False), Parameter('dynamic_labels', dict, value={'MODE': [{'value': 'walk', 'baseMode': 'WALKING', 'met_equivalent': 'WALKING', 'kgCo2PerKm': 0}, {'value': 'e-bike', 'baseMode': 'E_BIKE', 'met': {'ALL': {'range': [0, -1], 'mets': 4.9}}, 'kgCo2PerKm': 0.00728}, {'value': 'bike', 'baseMode': 'BICYCLING', 'met_equivalent': 'BICYCLING', 'kgCo2PerKm': 0}, {'value': 'bikeshare', 'baseMode': 'BICYCLING', 'met_equivalent': 'BICYCLING', 'kgCo2PerKm': 0}, {'value': 'scootershare', 'baseMode': 'E_SCOOTER', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.00894}, {'value': 'drove_alone', 'baseMode': 'CAR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.22031}, {'value': 'shared_ride', 'baseMode': 'CAR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.11015}, {'value': 'e_car_drove_alone', 'baseMode': 'E_CAR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.08216}, {'value': 'e_car_shared_ride', 'baseMode': 'E_CAR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.04108}, {'value': 'moped', 'baseMode': 'MOPED', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.05555}, {'value': 'taxi', 'baseMode': 'TAXI', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.30741}, {'value': 'bus', 'baseMode': 'BUS', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.20727}, {'value': 'train', 'baseMode': 'TRAIN', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.12256}, {'value': 'free_shuttle', 'baseMode': 'BUS', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.20727}, {'value': 'air', 'baseMode': 'AIR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.09975}, {'value': 'not_a_trip', 'baseMode': 'UNKNOWN', 'met_equivalent': 'UNKNOWN', 'kgCo2PerKm': 0}, {'value': 'other', 'baseMode': 'OTHER', 'met_equivalent': 'UNKNOWN', 'kgCo2PerKm': 0}], 'PURPOSE': [{'value': 'home'}, {'value': 'work'}, {'value': 'at_work'}, {'value': 'school'}, {'value': 'transit_transfer'}, {'value': 'shopping'}, {'value': 'meal'}, {'value': 'pick_drop_person'}, {'value': 'pick_drop_item'}, {'value': 'personal_med'}, {'value': 'access_recreation'}, {'value': 'exercise'}, {'value': 'entertainment'}, {'value': 'religious'}, {'value': 'other'}], 'REPLACED_MODE': [{'value': 'no_travel'}, {'value': 'walk'}, {'value': 'bike'}, {'value': 'bikeshare'}, {'value': 'scootershare'}, {'value': 'drove_alone'}, {'value': 'shared_ride'}, {'value': 'e_car_drove_alone'}, {'value': 'e_car_shared_ride'}, {'value': 'taxi'}, {'value': 'bus'}, {'value': 'train'}, {'value': 'free_shuttle'}, {'value': 'other'}], 'translations': {'en': {'walk': 'Walk', 'e-bike': 'E-bike', 'bike': 'Regular Bike', 'bikeshare': 'Bikeshare', 'scootershare': 'Scooter share', 'drove_alone': 'Gas Car Drove Alone', 'shared_ride': 'Gas Car Shared Ride', 'e_car_drove_alone': 'E-Car Drove Alone', 'e_car_shared_ride': 'E-Car Shared Ride', 'moped': 'Moped', 'taxi': 'Taxi/Uber/Lyft', 'bus': 'Bus', 'train': 'Train', 'free_shuttle': 'Free Shuttle', 'air': 'Air', 'not_a_trip': 'Not a trip', 'no_travel': 'No travel', 'home': 'Home', 'work': 'To Work', 'at_work': 'At Work', 'school': 'School', 'transit_transfer': 'Transit transfer', 'shopping': 'Shopping', 'meal': 'Meal', 'pick_drop_person': 'Pick-up/ Drop off Person', 'pick_drop_item': 'Pick-up/ Drop off Item', 'personal_med': 'Personal/ Medical', 'access_recreation': 'Access Recreation', 'exercise': 'Recreation/ Exercise', 'entertainment': 'Entertainment/ Social', 'religious': 'Religious', 'other': 'Other'}, 'es': {'walk': 'Caminando', 'e-bike': 'e-bicicleta', 'bike': 'Bicicleta', 'bikeshare': 'Bicicleta compartida', 'scootershare': 'Motoneta compartida', 'drove_alone': 'Coche de Gas, Condujo solo', 'shared_ride': 'Coche de Gas, Condujo con otros', 'e_car_drove_alone': 'e-coche, Condujo solo', 'e_car_shared_ride': 'e-coche, Condujo con ontras', 'moped': 'Ciclomotor', 'taxi': 'Taxi/Uber/Lyft', 'bus': 'Autobús', 'train': 'Tren', 'free_shuttle': 'Colectivo gratuito', 'air': 'Avión', 'not_a_trip': 'No es un viaje', 'no_travel': 'No viajar', 'home': 'Inicio', 'work': 'Trabajo', 'at_work': 'En el trabajo', 'school': 'Escuela', 'transit_transfer': 'Transbordo', 'shopping': 'Compras', 'meal': 'Comida', 'pick_drop_person': 'Recoger/ Entregar Individuo', 'pick_drop_item': 'Recoger/ Entregar Objeto', 'personal_med': 'Personal/ Médico', 'access_recreation': 'Acceder a Recreación', 'exercise': 'Recreación/ Ejercicio', 'entertainment': 'Entretenimiento/ Social', 'religious': 'Religioso', 'other': 'Otros'}}})] ``` Results: Overall Comparison | Default Mapping | Dynamic Config | |--------|--------| | Screenshot 2023-11-24 at 12 36 06 PM | Screenshot 2023-11-24 at 12 08 17 PM | 'e-bike' specific trip count by purpose All data Default | Default Mapping | Dynamic Config | |--------|--------| | Screenshot 2023-11-24 at 12 36 15 PM | Screenshot 2023-11-24 at 12 08 27 PM | 'e-bike' specific trip miles by replaced mode All data Default | Default Mapping | Dynamic Config | |--------|--------| | Screenshot 2023-11-24 at 12 36 22 PM | Screenshot 2023-11-24 at 12 08 35 PM | Average Miles for each replaced mode (w/Other) All data Default | Default Mapping | Dynamic Config | |--------|--------| | Screenshot 2023-11-24 at 12 36 27 PM | Screenshot 2023-11-24 at 12 08 41 PM | 'e-bike' specific Trip frequency All data | Default Mapping | Dynamic Config | |--------|--------| | Screenshot 2023-11-24 at 12 36 33 PM | Screenshot 2023-11-24 at 12 08 47 PM | 'e-bike' specific Trips per weekday | Default Mapping | Dynamic Config | |--------|--------| | Screenshot 2023-11-24 at 12 36 40 PM | Screenshot 2023-11-24 at 12 08 53 PM |

All the charts in both Default Mapping and Dynamic Config for Mode Specific Metrics looks identical.

iantei commented 9 months ago
Comparison of energy calculations notebook charts

Executed the notebook "Energy Calculations" for both the STUDY_CONFIG for comparison between default mapping and dynamic config. Steps executed: A. For Default Mapping (STUDY_CONFIG=stage-program): ``` (emission) root@1d89306b8d05:/usr/src/app/saved-notebooks# PYTHONPATH=.. python bin/generate_plots.py energy_calculations.ipynb default /usr/src/app/saved-notebooks/bin/generate_plots.py:30: SyntaxWarning: "is not" with a literal. Did you mean "!="? if r.status_code is not 200: About to download config from https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/configs/stage-program.nrel-op.json Successfully downloaded config with version 1 for Staging environment for testing programs only and data collection URL https://openpath-stage.nrel.gov/api/ label_options is unavailable for the dynamic_config in stage-program Running at 2023-11-24T19:24:31.229825+00:00 with args Namespace(plot_notebook='energy_calculations.ipynb', program='default', date=None) for range (, ) Running at 2023-11-24T19:24:31.278778+00:00 with params [Parameter('year', int), Parameter('month', int), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('is_debug_mode', bool, value=False), Parameter('dynamic_labels', dict, value={})] Running at 2023-11-24T19:24:46.321639+00:00 with params [Parameter('year', int, value=2020), Parameter('month', int, value=9), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('is_debug_mode', bool, value=False), Parameter('dynamic_labels', dict, value={})] Running at 2023-11-24T19:24:50.173058+00:00 with params [Parameter('year', int, value=2020), Parameter('month', int, value=10), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('is_debug_mode', bool, value=False), Parameter('dynamic_labels', dict, value={})] Running at 2023-11-24T19:24:53.866005+00:00 with params [Parameter('year', int, value=2020), Parameter('month', int, value=11), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('is_debug_mode', bool, value=False), Parameter('dynamic_labels', dict, value={})] Running at 2023-11-24T19:24:57.622034+00:00 with params [Parameter('year', int, value=2020), Parameter('month', int, value=12), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=True), Parameter('is_debug_mode', bool, value=False), Parameter('dynamic_labels', dict, value={})] ``` B. For Dynamic Config (STUDY_CONFIG=dev-emulator-program): ``` (emission) root@f1a86a1f3abd:/usr/src/app/saved-notebooks# PYTHONPATH=.. python bin/generate_plots.py energy_calculations.ipynb default /usr/src/app/saved-notebooks/bin/generate_plots.py:30: SyntaxWarning: "is not" with a literal. Did you mean "!="? if r.status_code is not 200: About to download config from https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/configs/dev-emulator-program.nrel-op.json Successfully downloaded config with version 1 for Development environment (program) and data collection URL default Dynamic labels download was successful for nrel-openpath-deploy-configs: dev-emulator-program Running at 2023-11-24T18:41:28.356249+00:00 with args Namespace(plot_notebook='energy_calculations.ipynb', program='default', date=None) for range (, ) Running at 2023-11-24T18:41:28.390824+00:00 with params [Parameter('year', int), Parameter('month', int), Parameter('program', str, value='default'), Parameter('study_type', str, value='program'), Parameter('mode_of_interest', str, value='e-bike'), Parameter('include_test_users', bool, value=False), Parameter('is_debug_mode', bool, value=False), Parameter('dynamic_labels', dict, value={'MODE': [{'value': 'walk', 'baseMode': 'WALKING', 'met_equivalent': 'WALKING', 'kgCo2PerKm': 0}, {'value': 'e-bike', 'baseMode': 'E_BIKE', 'met': {'ALL': {'range': [0, -1], 'mets': 4.9}}, 'kgCo2PerKm': 0.00728}, {'value': 'bike', 'baseMode': 'BICYCLING', 'met_equivalent': 'BICYCLING', 'kgCo2PerKm': 0}, {'value': 'bikeshare', 'baseMode': 'BICYCLING', 'met_equivalent': 'BICYCLING', 'kgCo2PerKm': 0}, {'value': 'scootershare', 'baseMode': 'E_SCOOTER', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.00894}, {'value': 'drove_alone', 'baseMode': 'CAR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.22031}, {'value': 'shared_ride', 'baseMode': 'CAR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.11015}, {'value': 'e_car_drove_alone', 'baseMode': 'E_CAR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.08216}, {'value': 'e_car_shared_ride', 'baseMode': 'E_CAR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.04108}, {'value': 'moped', 'baseMode': 'MOPED', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.05555}, {'value': 'taxi', 'baseMode': 'TAXI', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.30741}, {'value': 'bus', 'baseMode': 'BUS', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.20727}, {'value': 'train', 'baseMode': 'TRAIN', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.12256}, {'value': 'free_shuttle', 'baseMode': 'BUS', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.20727}, {'value': 'air', 'baseMode': 'AIR', 'met_equivalent': 'IN_VEHICLE', 'kgCo2PerKm': 0.09975}, {'value': 'not_a_trip', 'baseMode': 'UNKNOWN', 'met_equivalent': 'UNKNOWN', 'kgCo2PerKm': 0}, {'value': 'other', 'baseMode': 'OTHER', 'met_equivalent': 'UNKNOWN', 'kgCo2PerKm': 0}], 'PURPOSE': [{'value': 'home'}, {'value': 'work'}, {'value': 'at_work'}, {'value': 'school'}, {'value': 'transit_transfer'}, {'value': 'shopping'}, {'value': 'meal'}, {'value': 'pick_drop_person'}, {'value': 'pick_drop_item'}, {'value': 'personal_med'}, {'value': 'access_recreation'}, {'value': 'exercise'}, {'value': 'entertainment'}, {'value': 'religious'}, {'value': 'other'}], 'REPLACED_MODE': [{'value': 'no_travel'}, {'value': 'walk'}, {'value': 'bike'}, {'value': 'bikeshare'}, {'value': 'scootershare'}, {'value': 'drove_alone'}, {'value': 'shared_ride'}, {'value': 'e_car_drove_alone'}, {'value': 'e_car_shared_ride'}, {'value': 'taxi'}, {'value': 'bus'}, {'value': 'train'}, {'value': 'free_shuttle'}, {'value': 'other'}], 'translations': {'en': {'walk': 'Walk', 'e-bike': 'E-bike', 'bike': 'Regular Bike', 'bikeshare': 'Bikeshare', 'scootershare': 'Scooter share', 'drove_alone': 'Gas Car Drove Alone', 'shared_ride': 'Gas Car Shared Ride', 'e_car_drove_alone': 'E-Car Drove Alone', 'e_car_shared_ride': 'E-Car Shared Ride', 'moped': 'Moped', 'taxi': 'Taxi/Uber/Lyft', 'bus': 'Bus', 'train': 'Train', 'free_shuttle': 'Free Shuttle', 'air': 'Air', 'not_a_trip': 'Not a trip', 'no_travel': 'No travel', 'home': 'Home', 'work': 'To Work', 'at_work': 'At Work', 'school': 'School', 'transit_transfer': 'Transit transfer', 'shopping': 'Shopping', 'meal': 'Meal', 'pick_drop_person': 'Pick-up/ Drop off Person', 'pick_drop_item': 'Pick-up/ Drop off Item', 'personal_med': 'Personal/ Medical', 'access_recreation': 'Access Recreation', 'exercise': 'Recreation/ Exercise', 'entertainment': 'Entertainment/ Social', 'religious': 'Religious', 'other': 'Other'}, 'es': {'walk': 'Caminando', 'e-bike': 'e-bicicleta', 'bike': 'Bicicleta', 'bikeshare': 'Bicicleta compartida', 'scootershare': 'Motoneta compartida', 'drove_alone': 'Coche de Gas, Condujo solo', 'shared_ride': 'Coche de Gas, Condujo con otros', 'e_car_drove_alone': 'e-coche, Condujo solo', 'e_car_shared_ride': 'e-coche, Condujo con ontras', 'moped': 'Ciclomotor', 'taxi': 'Taxi/Uber/Lyft', 'bus': 'Autobús', 'train': 'Tren', 'free_shuttle': 'Colectivo gratuito', 'air': 'Avión', 'not_a_trip': 'No es un viaje', 'no_travel': 'No viajar', 'home': 'Inicio', 'work': 'Trabajo', 'at_work': 'En el trabajo', 'school': 'Escuela', 'transit_transfer': 'Transbordo', 'shopping': 'Compras', 'meal': 'Comida', 'pick_drop_person': 'Recoger/ Entregar Individuo', 'pick_drop_item': 'Recoger/ Entregar Objeto', 'personal_med': 'Personal/ Médico', 'access_recreation': 'Acceder a Recreación', 'exercise': 'Recreación/ Ejercicio', 'entertainment': 'Entretenimiento/ Social', 'religious': 'Religioso', 'other': 'Otros'}}})] ``` Results: Sketch of 'e-bike' specific emission Impact All data Default | Default Mapping | Dynamic Config | |--------|--------| | Screenshot 2023-11-24 at 12 37 30 PM | Screenshot 2023-11-24 at 12 13 40 PM |

The computation for Default Mapping is based on auxiliary_files/energy_intensity while the computation for Dynamic Config is based on https://github.com/e-mission/nrel-openpath-deploy-configs/blob/main/label_options/example-program-label-options.json.

The difference in these emissions have been documented here in the Issue section. https://github.com/e-mission/em-public-dashboard/issues/89#issuecomment-1750013681

The explanation for this is documented above. https://github.com/e-mission/em-public-dashboard/pull/91#issuecomment-1788482220

iantei commented 9 months ago
Response for the above comments are provided below [Generic Metrics Notebook Charts Difference Explaination]

> > Overall the charts looks identical. > > Not really. I still see differences in: > > 1. Trip count by purpose > > I see your comment around > > > Note: There is no mapping for "pilot_ebike" to "E-bike". Therefore, these mapping has been transformed into "Others" in "Number of Commute Trips" and "Trip count by Purpose" charts above. > > But "Trip count by Purpose" does not display modes, so a difference in the e-bike label should not make any difference. And there is no "other" in the purpose charts anyway. It does cause the large "other" in "Number of trips", so I have not flagged that. For Trip count by Purpose, we have the following labels (identical in both Default Mapping and Dynamic Config) with the numeric representation of each labels | Purpose | Number | |--------|--------| | Home | 4458 | | Recreation/ Exercise | 2575 | | Work | 4655 | | Entertainment/ Social | 1306 | | Shopping | 2156 | | Personal/ Medical | 947 | | Meal | 847 | All these labels are available on both `Default Mapping` and `Dynamic Config`. Whilst in the `Dynamic Config`, few more labels are introduced as. `"At Work"`, `"Other"`, `"Pickup / Drop off item"`, `"Pickup / Drop off Person"`. These are equivalent to the `"Other"` label present in the `default mapping.` Further clarification showing comparison between two chart's label and it's value representation. | Default Mapping | Dynamic Config | |--------|--------| | ![Screenshot 2023-11-28 at 3 15 45 PM](https://github.com/e-mission/em-public-dashboard/assets/26689347/60e8e40f-c148-407d-ac50-8fce30f79116) | ![Screenshot 2023-11-28 at 3 17 07 PM](https://github.com/e-mission/em-public-dashboard/assets/26689347/ffe9de59-da6b-4764-8b79-7a10444f8fc4) | As mentioned above, "Home", "Recreation/ Exercise", "Work" - "To Work", "Entertainment/Social", "Shopping", "Personal/Medical" and "Meal" have same corresponding values. Lets understand the 'Other' label in the pie-chart. ``` For Default: Other : 4360(Other) + 431 (not_a_trip) + 388 (School) + Pick-up/Drop off (163) + Religious (154) + Transit Transfer (114) = 5610 For Dynamic Config: Other: 1649 (Other) + 388 (School) + Access Recreation (211) + Religious (154) + Transit Transfer (114) = 2516. ``` For Dynamic Config, we have distinct new labels represented on the chart as: `Pick-up/ Drop off Person` and `Pick-up/ Drop off Item` > 2. Trip count under 10 miles is comparing modes to purpose I understand this comment is in reference with "Mode choice for Trips under 10 miles". There was a wrong comparison in the charts above, which I have already updated. Now, explanation for the different in representation of the charts. Code snippet to show we're using `Mode_confirm`. ``` labels_d10 = expanded_ct.loc[(expanded_ct['distance_miles'] <= 10)].Mode_confirm.value_counts(dropna=True).keys().tolist() values_d10 = expanded_ct.loc[(expanded_ct['distance_miles'] <= 10)].Mode_confirm.value_counts(dropna=True).tolist() ``` The difference in representation is because of the following reasons. For `Default Mapping` we have the following mapping (as in [mode_labels.csv](https://github.com/e-mission/em-public-dashboard/blob/main/viz_scripts/auxiliary_files/mode_labels.csv) ): ``` pilot_ebike,pilot_ebike,E-bike e-bike,e-bike,E-bike ``` while with the `Dynamic Config`, we just have (as in [example_program_label_option)](https://github.com/e-mission/nrel-openpath-deploy-configs/blob/main/label_options/example-program-label-options.json) ``` {"value":"e-bike", "baseMode":"E_BIKE", "met": {"ALL": {"range": [0, -1], "mets": 4.9}}, "kgCo2PerKm": 0.00728}, ... "translations": { "en": { "walk": "Walk", "e-bike": "E-bike", ... } ``` in the reference example of config which I used to test. [https://github.com/e-mission/nrel-openpath-deploy-configs/blob/main/label_options/example-program-label-options.json](https://github.com/e-mission/nrel-openpath-deploy-configs/blob/main/label_options/example-program-label-options.json) Comparing labels and their corresponding values: | Default Mapping | Dynamic Config | |--------|--------| | ![Default_under10miles](https://github.com/e-mission/em-public-dashboard/assets/26689347/423aa012-d7df-4e66-89a1-e5991c80ac48) | ![Dynamic_under10miles](https://github.com/e-mission/em-public-dashboard/assets/26689347/b3b3a4bf-f829-4300-a20c-21e52f639900) | All the labels have same values except `Other` and `E-bike`. Now, let us evaluate the sum of these labels. For Default: `3853 (E-bike) + 180 (Other) = 4033` For Dynamic: `25 (E-bike) + 4008 (Other) = 4033` Sum of `Other` and `E-bike` labels in both of these cases give the total value of `4033`. This shows that because of the change in label for `E-bike` in the example config used for testing [program_label_options](https://github.com/e-mission/nrel-openpath-deploy-configs/blob/main/label_options/example-program-label-options.json), there is difference in representation. But the representation in both the charts are correct. > 3. Trip miles by mode The addition of `Air` mode has resulted in this difference of representation. Comparison of Average (miles) for `Mode_confirm` between `Default Mapping` vs `Dynamic Config` | Default Mapping | Dynamic Config | |--------|--------| | ![DefaultMapping_TripMilesByMode](https://github.com/e-mission/em-public-dashboard/assets/26689347/75850cf4-642c-4d27-b301-7a7bc250c67e)| ![DynamicConfig_TripMilesByMode](https://github.com/e-mission/em-public-dashboard/assets/26689347/fc0e9aa3-b1ca-49f0-a8df-8426e5128f5e) | The Y-axis represents of Average(miles), with the Mode_confirm represented on the X-axis. As we can see from above, we have difference in `Other` and `E-Bike`. We didn't have `Air` label in `Default Mapping` which is available for the example `Dynamic Config`. Because of the no mapping translation from `pilot_ebike` to `E-Bike`, the average miles by `E-Bike` commute has dropped and added into `Other` label. Therefore, there is a difference in representation of these values in the chart. Re-checking, the total miles in both of these charts. Adding up the total `Total (miles)` in both of these gives same value as `142600.44744852`. > 4. Average trip length The representation includes `Air` mode, which has huge number of trip length. Therefore, the other modes are not represented as previously. > Also, "generic_metrics" as an example (note the e.g. before it). I would like to see at least a few metrics from the mode specific and energy/emission notebooks. > > > I still want to see all the outputs (e.g. generic metrics) one last time to make sure that there are no regressions Updated the comparison charts between mode specific and energy emissions notebooks above.

shankari commented 9 months ago

I am not going to hold up the merge for this, but in the future, please test on a dataset with > 1 user and > 25 confirmed e-bike trips.

https://github.com/e-mission/em-public-dashboard/pull/91#issuecomment-1826048250 and https://github.com/e-mission/em-public-dashboard/pull/91#issuecomment-1826055439

I am not sure we would have caught all the errors earlier with such a small dataset. Please update the outputs into this PR after the merge with results from the larger dataset.

Please also note that I am squash-merging here, so please account for that while pulling post-merge.