Closed shankari closed 2 years ago
Another potential addition: Add calculation details to FAQ
Another potential addition: Add "air" mode to have the best estimate of carbon footprint
wrt the "air" mode addition, we should also go through and fix the existing labels to say "air" so that the footprint calculations work. This is by necessity manual since a human needs to go through and find the mappings. Also, we need to change not only the user mappings, but also any inferred values that use the user mappings.
So this change happened in multiple steps.
Printing out the user inputs is fairly straightforward because we can directly use a projection. However, the inferred labels are harder because they are stored as lists we need to iterate over. So I ended up writing the attached script.
The result of the mapping on staging is as below. This makes the mapping a little tricky - how do we deal with car-fly
or fly-drive-bike-drive-fly
? We don't want to override the user input and to lose the information that is captured in those labels.
So the current decision is to only map the uncomplicated labels. Users can change the more complicated labels later if they wish, but we will not modify them. Otherwise, the complicated labels will continue generate a range. This is consistent with what would have happened if we did have an air
mode.
Connecting to database URL stage-db
---------- inputs ----------
__________ manual/mode_confirm __________
['airplane', 'bike', 'bikeshare', 'bus', 'car-fly', 'dog_walk', 'drove_alone', 'electric_car', 'flight', 'fly-drive-bike-drive-fly', 'free_shuttle', 'gondola', 'houseboat', 'kayak', 'motorboat', 'multi-modal', 'multi-modal_car- regular bike- car', 'multi-modal_drive to bike to drive', 'multi_modal', 'not_a_trip', 'pilot_ebike', 'plane', 'pontoon_boat', 'run', 'sailboat', 'scooter_(non-motorized, non-share)', 'scootershare', 'shared_ride', 'sharedride_and walk', 'sharedrideandwalk', 'ski', 'subway', 'taxi', 'train', 'tramway', 'walk', 'walk_+ drove alone']
__________ analysis/confirmed_trip __________
['airplane', 'bike', 'bikeshare', 'bus', 'car-fly', 'drove_alone', 'electric_car', 'fly-drive-bike-drive-fly', 'free_shuttle', 'gondola', 'houseboat', 'kayak', 'motorboat', 'multi-modal', 'multi-modal_car- regular bike- car', 'multi-modal_drive to bike to drive', 'multi_modal', 'not_a_trip', 'pilot_ebike', 'plane', 'pontoon_boat', 'run', 'sailboat',
'scooter_(non-motorized, non-share)', 'scootershare', 'shared_ride', 'sharedride_and walk', 'sharedrideandwalk', 'ski', 'subway', 'taxi', 'train', 'tramway', 'walk', 'walk_+ drove alone']
---------- inferred_labels ----------
__________ label predictions __________
['electric_car', 'multi-modal', 'pilot_ebike', 'sharedride_and walk', 'run', 'walk_+ drove alone', 'multi-modal_car- regular bike- car', 'pontoon_boat', 'motorboat', 'not_a_trip', 'tramway', 'houseboat', 'shared_ride', 'gondola', 'bike', 'multi-modal_drive to bike to drive', 'taxi', 'plane', 'free_shuttle', 'train', 'sharedrideandwalk', 'scootershare', 'drove_alone', 'scooter_(non-motorized, non-share)', 'bikeshare', 'bus', 'kayak', 'multi_modal', 'walk']
__________ inferred trips __________
['electric_car', 'multi-modal', 'pilot_ebike', 'sharedride_and walk', 'run', 'walk_+ drove alone', 'multi-modal_car- regular bike- car', 'pontoon_boat', 'motorboat', 'not_a_trip', 'tramway', 'houseboat', 'shared_ride', 'gondola', 'bike', 'multi-modal_drive to bike to drive', 'taxi', 'plane', 'free_shuttle', 'train', 'sharedrideandwalk', 'scootershare', 'drove_alone', 'scooter_(non-motorized, non-share)', 'bikeshare', 'bus', 'kayak', 'multi_modal', 'walk']
__________ expected trips __________
['electric_car', 'multi-modal', 'pilot_ebike', 'sharedride_and walk', 'run', 'walk_+ drove alone', 'multi-modal_car- regular bike- car', 'pontoon_boat', 'motorboat', 'not_a_trip', 'tramway', 'houseboat', 'shared_ride', 'gondola', 'bike', 'multi-modal_drive to bike to drive', 'taxi', 'plane', 'free_shuttle', 'train', 'sharedrideandwalk', 'scootershare', 'drove_alone', 'scooter_(non-motorized, non-share)', 'bikeshare', 'bus', 'kayak', 'multi_modal', 'walk']
__________ confirmed trips __________
['electric_car', 'multi-modal', 'pilot_ebike', 'sharedride_and walk', 'run', 'walk_+ drove alone', 'multi-modal_car- regular bike- car', 'pontoon_boat', 'motorboat', 'not_a_trip', 'tramway', 'houseboat', 'shared_ride', 'gondola', 'bike', 'multi-modal_drive to bike to drive', 'taxi', 'plane', 'free_shuttle', 'train', 'sharedrideandwalk', 'scootershare', 'drove_alone', 'scooter_(non-motorized, non-share)', 'bikeshare', 'bus', 'kayak', 'multi_modal', 'walk']
Note also that the air trips are so rare that they don't make it to the model or to the inferred labels. Let's see if that is true for other programs as well.
Alas, no. The staging inferred labels include plane
and the 4c inferred labels include airplane
Fortunately, each of the inferred labels is fairly unique and has only one entry.
Connecting to database URL stage-db
__________ label predictions __________
[{'labels': {'mode_confirm': 'plane', 'purpose_confirm': 'travel', 'replaced_mode': 'plane'}, 'p': 0.8}]
[{'labels': {'mode_confirm': 'plane', 'purpose_confirm': 'travel', 'replaced_mode': 'plane'}, 'p': 0.8}]
[ObjectId('611fde31688f92fbb6e6bf33'), ObjectId('611fde32688f92fbb6e6bfc3')]
[ObjectId('611fde31688f92fbb6e6bf33'), ObjectId('611fde32688f92fbb6e6bfc3')]
__________ label predictions __________
[{'labels': {'mode_confirm': 'airplane', 'purpose_confirm': 'entertainment', 'replaced_mode': 'no_travel'}, 'p': 0.8}]
[{'labels': {'mode_confirm': 'airplane', 'purpose_confirm': 'entertainment', 'replaced_mode': 'no_travel'}, 'p': 0.8}]
[{'labels': {'mode_confirm': 'airplane', 'purpose_confirm': 'home'}, 'p': 0.8}]
[ObjectId('61208a2fb8ec5759a7bfd2c5'), ObjectId('61208a2fb8ec5759a7bfd2cb'), ObjectId('61208a30b8ec5759a7bfd32b')]
[ObjectId('61208a2fb8ec5759a7bfd2c5'), ObjectId('61208a2fb8ec5759a7bfd2cb'), ObjectId('61208a30b8ec5759a7bfd32b')]
Created a script and fixed both the user inputs and the inferred labels
Connecting to database URL stage-db
---------- inputs ----------
__________ manual/mode_confirm __________
<pymongo.results.UpdateResult object at 0x7fe29c85eaa0>
__________ analysis/confirmed_trip __________
<pymongo.results.UpdateResult object at 0x7fe29c869690>
---------- inferred_labels ----------
__________ label predictions __________
Fixing projection {'_id': ObjectId('611fde31688f92fbb6e6bf33'), 'data': {'prediction': [{'labels': {'mode_confirm': 'plane', 'purpose_confirm': 'travel', 'replaced_mode': 'plane'}, 'p': 0.8}]}}
Update response <pymongo.results.UpdateResult object at 0x7fe28fb89e10>
Fixed projection {'_id': ObjectId('611fde31688f92fbb6e6bf33'), 'data': {'prediction': [{'labels': {'mode_confirm': 'air', 'purpose_confirm': 'travel', 'replaced_mode': 'plane'}, 'p': 0.8}]}}
Fixing projection {'_id': ObjectId('611fde32688f92fbb6e6bfc3'), 'data': {'prediction': [{'labels': {'mode_confirm': 'plane', 'purpose_confirm': 'travel', 'replaced_mode': 'plane'}, 'p': 0.8}]}}
Update response <pymongo.results.UpdateResult object at 0x7fe296f68280>
Fixed projection {'_id': ObjectId('611fde32688f92fbb6e6bfc3'), 'data': {'prediction': [{'labels': {'mode_confirm': 'air', 'purpose_confirm': 'travel', 'replaced_mode': 'plane'}, 'p': 0.8}]}}
None
and we now only have air
Connecting to database URL stage-db
---------- inputs ----------
__________ manual/mode_confirm __________
['air', 'bike', 'bikeshare', 'bus', 'car-fly', 'dog_walk', 'drove_alone', 'electric_car', 'fly-drive-bike-drive-fly', 'free_shuttle', 'gondola', 'houseboat', 'kayak', 'motorboat', 'multi-modal', 'multi-modal_car- regular bike- car', 'multi-modal_drive to bike to drive', 'multi_modal', 'not_a_trip', 'pilot_ebike', 'pontoon_boat', 'run', 'sailboat', 'scooter_(non-motorized, non-share)', 'scootershare', 'shared_ride', 'sharedride_and walk', 'sharedrideandwalk', 'ski', 'subway', 'taxi', 'train', 'tramway', 'walk', 'walk_+ drove alone']
__________ analysis/confirmed_trip __________
['air', 'bike', 'bikeshare', 'bus', 'car-fly', 'drove_alone', 'electric_car', 'fly-drive-bike-drive-fly', 'free_shuttle', 'gondola', 'houseboat', 'kayak', 'motorboat', 'multi-modal', 'multi-modal_car- regular bike- car', 'multi-modal_drive to bike to drive', 'multi_modal', 'not_a_trip', 'pilot_ebike', 'pontoon_boat', 'run', 'sailboat', 'scooter_(non-motorized, non-share)', 'scootershare', 'shared_ride', 'sharedride_and walk', 'sharedrideandwalk', 'ski', 'subway', 'taxi', 'train', 'tramway', 'walk', 'walk_+ drove alone']
---------- inferred_labels ----------
__________ label predictions __________
['train', 'multi-modal', 'sharedrideandwalk', 'sharedride_and walk', 'pontoon_boat', 'free_shuttle', 'scooter_(non-motorized, non-share)', 'multi-modal_drive to bike to drive', 'gondola', 'run', 'kayak', 'taxi', 'multi_modal', 'houseboat', 'walk_+ drove alone', 'not_a_trip', 'multi-modal_car- regular bike- car', 'tramway', 'motorboat', 'pilot_ebike', 'shared_ride', 'bike', 'scootershare', 'drove_alone', 'bus', 'bikeshare', 'electric_car', 'air', 'walk']
__________ inferred trips __________
['train', 'multi-modal', 'sharedrideandwalk', 'sharedride_and walk', 'pontoon_boat', 'free_shuttle', 'scooter_(non-motorized, non-share)', 'multi-modal_drive to bike to drive', 'gondola', 'run', 'kayak', 'taxi', 'multi_modal', 'houseboat', 'walk_+ drove alone', 'not_a_trip', 'multi-modal_car- regular bike- car', 'tramway', 'motorboat', 'pilot_ebike', 'shared_ride', 'bike', 'scootershare', 'drove_alone', 'bus', 'bikeshare', 'electric_car', 'air', 'walk']
__________ expected trips __________
['train', 'multi-modal', 'sharedrideandwalk', 'sharedride_and walk', 'pontoon_boat', 'free_shuttle', 'scooter_(non-motorized, non-share)', 'multi-modal_drive to bike to drive', 'gondola', 'run', 'kayak', 'taxi', 'multi_modal', 'houseboat', 'walk_+ drove alone', 'not_a_trip', 'multi-modal_car- regular bike- car', 'tramway', 'motorboat', 'pilot_ebike', 'shared_ride', 'bike', 'scootershare', 'drove_alone', 'bus', 'bikeshare', 'electric_car', 'air', 'walk']
__________ confirmed trips __________
['train', 'multi-modal', 'sharedrideandwalk', 'sharedride_and walk', 'pontoon_boat', 'free_shuttle', 'scooter_(non-motorized, non-share)', 'multi-modal_drive to bike to drive', 'gondola', 'run', 'kayak', 'taxi', 'multi_modal', 'houseboat', 'walk_+ drove alone', 'not_a_trip', 'multi-modal_car- regular bike- car', 'tramway', 'motorboat', 'pilot_ebike', 'shared_ride', 'bike', 'scootershare', 'drove_alone', 'bus', 'bikeshare', 'electric_car', 'air', 'walk']
Related scripts:
a tmp/modify_unique_user_inputs.py
a tmp/print_air_inferred_labels.py
a tmp/print_unique_labels.py
Running them on the server was:
PROGRAM=$1
sudo docker cp /tmp/print_unique_labels.py $PROGRAM-stack_$PROGRAM-analysis-server_1:/tmp
sudo docker exec -it $PROGRAM-stack_$PROGRAM-analysis-server_1 /bin/bash -c 'cd e-mission-server && \
source setup/activate.sh && \
echo "Running at "`date` && \
cat conf/storage/db.conf && \
./e-mission-py.bash /tmp/print_unique_labels.py'
Related logs: update_air_mode_results.log.gz post_modification_check.log.gz
For smartphone calculations, the EPA says: 8.22 x 10^-6 metric tons CO2/smartphone charged https://www.epa.gov/energy/greenhouse-gases-equivalencies-calculator-calculations-and-references
1 metric ton = 1000 kg So this is 8.22 x 10^-3 kg CO2/smartphone charged So x kg CO2 = x / 8.22 x 10^-3 smartphone charges
Feedback on dashboard changes fit-and-finish