-
Notifications
You must be signed in to change notification settings - Fork 119
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
Create a new function to expand final labels #846
Create a new function to expand final labels #846
Conversation
This will expand the user labels if they exist, and expand the highest probability inferred label if we did not prompt the user. Basically, this is now consistent with e-mission/e-mission-docs#688 (comment) There were some minor trickinesses working with this data structure and pandas. - We had to expand the expectation field to filter by to_label and then - We had to create a separate dataframe for the inferred labels and the apply a custom filter to them to pick the one with the max probability - We had to ensure that rows didn't appear twice - i.e. once for user inputs and once for inferred labels. This is true even if the user_inputs were not filled out; without changes, we would end up with both N/A and the inferred label for the same row. And we had to keep the indices constant throughout these changes. Added multiple tests, both of the individual pandas steps and the complete function to test this fairly complex piece of code. Testing done: - Ran the newly added tests Next steps: - Change the metrics code and the leaderboard to use the new functions
By adding an expected failure and the correct version with drop_na
To test, we look for trips that will not be displayed to the user and do not Our test user has two such trips:
Focusing on the first one, we set the current date on the phone to Jul 23,
Why does the 8:58 trip not show up as "unlabeled"? |
Included this into the metrics detection code by replacing:
To test, we look for trips that will not be displayed to the user and do not Our test user has two such trips:
Focusing on the first one, we set the current date on the phone to Jul 23,
Why does the 8:58 trip not show up as "unlabeled"?
Let's look at the logs to figure out what is going on. It looks like the query was from 9th to 22nd UTC. The UI displays 16th to 23rd. And with the time difference, 22nd UTC is before the 21st 20:00 The query range is
|
These are UI questions. But it certainly looks like the mapping works correctly since the 5:17 trip does not show up as unlabeled. |
One-line fix consistent with e-mission#846 (comment)
Quick performance check to ensure that we don't have to back this out again: Before
After
Not too terrible in terms of % but still bad wrt absolute numbers (2 secs). Let's see if we can change the structure to get it back down... |
First, doing some basic repetitions: Before
After
This doesn't actually seem that much worse. |
Let's do some quick checks for repeated calls before moving on. DB queryWe only do one query per call
Added post-processingWe seem to be calling this a lot. We call the "unlabeled replace" code 52 times per call. This is because we perform the post-processing in the Let's move this up to the queried data, which should help. It is not going to result in a 4x speedup since it doesn't change the query time, but hopefully it will help quite a bit.
|
Drop the dashboard metrics query time from 12 secs to 0.6 secs by post-processing for the user input only at the beginning instead of for every group. The native code speedups in pandas really do work! Testing done: - Reloaded the dashboard multiple times - Consistently got a time of under one second ``` $ grep "END POST.*timestamp" /var/tmp/webserver.log 2022-01-14 13:47:35,583:DEBUG:123145442308096:END POST /result/metrics/timestamp 742fbefa-e7d7-45a9-bdf6-44659d21e0fa 0.6526408195495605 2022-01-14 13:47:35,632:DEBUG:123145447563264:END POST /result/metrics/timestamp 0.701042890548706 2022-01-14 13:47:39,820:DEBUG:123145463328768:END POST /result/metrics/timestamp 742fbefa-e7d7-45a9-bdf6-44659d21e0fa 0.5813801288604736 2022-01-14 13:47:39,862:DEBUG:123145458073600:END POST /result/metrics/timestamp 0.6311750411987305 2022-01-14 13:47:43,155:DEBUG:123145421287424:END POST /result/metrics/timestamp 742fbefa-e7d7-45a9-bdf6-44659d21e0fa 0.6370611190795898 2022-01-14 13:47:43,198:DEBUG:123145426542592:END POST /result/metrics/timestamp 0.6914339065551758 2022-01-14 13:47:45,669:DEBUG:123145442308096:END POST /result/metrics/timestamp 742fbefa-e7d7-45a9-bdf6-44659d21e0fa 0.5435740947723389 2022-01-14 13:47:45,712:DEBUG:123145437052928:END POST /result/metrics/timestamp 0.6239280700683594 2022-01-14 13:47:49,359:DEBUG:123145463328768:END POST /result/metrics/timestamp 742fbefa-e7d7-45a9-bdf6-44659d21e0fa 0.7017340660095215 2022-01-14 13:47:49,409:DEBUG:123145452818432:END POST /result/metrics/timestamp 0.7662367820739746 ```
Whoa! It improved performance by 10x!
|
…ueries This is the complement to 0c07b8c
This will expand the user labels if they exist, and expand the highest
probability inferred label if we did not prompt the user.
Basically, this is now consistent with
e-mission/e-mission-docs#688 (comment)
There were some minor trickinesses working with this data structure and pandas.
custom filter to them to pick the one with the max probability
and once for inferred labels. This is true even if the user_inputs were not
filled out; without changes, we would end up with both N/A and the inferred
label for the same row.
And we had to keep the indices constant throughout these changes.
Added multiple tests, both of the individual pandas steps and the complete
function to test this fairly complex piece of code.
Testing done:
Next steps: