Repository navigation
Incorrect values in jhu-csse:confirmed_incidence_num #1685
Copy link
Copy link
Closed
Labels
data qualityMissing data, weird data, broken dataMissing data, weird data, broken data
Description
Working on JIT A/B tests cmu-delphi/delphi-epidata#947, I found this.
Actual Behavior:
The incidence values in the county '02100' don't agree with their cumulative counterparts.
from epidatpy.request import EpiRange, Epidata
manual_incidence = Epidata.covidcast("jhu-csse", "confirmed_cumulative_num", "day", "county", EpiRange(20200620, 20200630), "02100").df().value.diff()[1:]
api_incidence = Epidata.covidcast("jhu-csse", "confirmed_incidence_num", "day", "county", EpiRange(20200621, 20200630), "02100").df().value
manual_incidence.to_numpy()
# array([ 0., 0., 1., 2., 0., 0., 0., 0., 0., -3.])
api_incidence.to_numpy()
# array([ 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.])Expected behavior
These should match. The dates line up.
Context
Looking at confirmed_cumulative_num, there's definitely a jump of 2 cases on 2020-06-24
Epidata.covidcast("jhu-csse", "confirmed_cumulative_num", "day", "county", EpiRange(20200620, 20200630), "02100").df()
# source signal geo_type geo_value time_type time_value issue lag value stderr sample_size direction missing_value missing_stderr missing_sample_size
# 0 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-20 2020-06-21 1 2.0 None None None 0 0 0
# 1 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-21 2020-10-29 130 2.0 None None None 0 0 0
# 2 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-22 2020-06-23 1 2.0 None None None 0 0 0
# 3 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-23 2020-06-24 1 3.0 None None None 0 0 0
# 4 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-24 2021-04-01 281 5.0 None None None 0 0 0
# 5 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-25 2021-04-01 280 5.0 None None None 0 0 0
# 6 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-26 2021-04-01 279 5.0 None None None 0 0 0
# 7 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-27 2021-04-01 278 5.0 None None None 0 0 0
# 8 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-28 2021-04-01 277 5.0 None None None 0 0 0
# 9 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-29 2021-04-01 276 5.0 None None None 0 0 0
# 10 jhu-csse confirmed_cumulative_num county 02100 day 2020-06-30 2020-07-01 1 2.0 None None None 0 0 0but incidence doesn't reflect that
Epidata.covidcast("jhu-csse", "confirmed_incidence_num", "day", "county", EpiRange(20200620, 20200630), "02100").df()
# source signal geo_type geo_value time_type time_value issue lag value stderr sample_size direction missing_value missing_stderr missing_sample_size
# 0 jhu-csse confirmed_incidence_num county 02100 day 2020-06-20 2020-06-21 1 0.0 None None None 0 0 0
# 1 jhu-csse confirmed_incidence_num county 02100 day 2020-06-21 2020-10-29 130 0.0 None None None 0 0 0
# 2 jhu-csse confirmed_incidence_num county 02100 day 2020-06-22 2020-06-23 1 0.0 None None None 0 0 0
# 3 jhu-csse confirmed_incidence_num county 02100 day 2020-06-23 2020-06-24 1 1.0 None None None 0 0 0
# 4 jhu-csse confirmed_incidence_num county 02100 day 2020-06-24 2021-04-01 281 0.0 None None None 0 0 0
# 5 jhu-csse confirmed_incidence_num county 02100 day 2020-06-25 2021-04-01 280 0.0 None None None 0 0 0
# 6 jhu-csse confirmed_incidence_num county 02100 day 2020-06-26 2021-04-01 279 0.0 None None None 0 0 0
# 7 jhu-csse confirmed_incidence_num county 02100 day 2020-06-27 2021-04-01 278 0.0 None None None 0 0 0
# 8 jhu-csse confirmed_incidence_num county 02100 day 2020-06-28 2021-04-01 277 0.0 None None None 0 0 0
# 9 jhu-csse confirmed_incidence_num county 02100 day 2020-06-29 2021-04-01 276 0.0 None None None 0 0 0
# 10 jhu-csse confirmed_incidence_num county 02100 day 2020-06-30 2020-07-01 1 0.0 None None None 0 0 0Looking at the issue column, it looks like the dates 2020-06-24 -- 2020-06-29 were last updated on 2021-04-01, unlike the previous dates. Maybe this was a patch that didn't get computed correctly?
But what's surprising to me is that the jhu indicator processes all the dates every single time it runs and writes them to CSV files, which should've been caught in the archiver diffs. So:
- either the diff isn't correctly computed in the indicator
- the archiver isn't detecting this change correctly
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
data qualityMissing data, weird data, broken dataMissing data, weird data, broken data
Activity
[-]Discrepancy in `jhu-csse:confirmed_incidence_num`[/-][+]Incorrect values in `jhu-csse:confirmed_incidence_num`[/+]dshemetov commentedon Aug 23, 2022
I have a batch of other possible errors in the incidence signal. This is coming from the comparison between live code and JIT. The live code
valuecolumn is on the left, while the JIT code is on the right. You can se that the -3.0 difference on 20200630 is another live code error in the above queries.dshemetov commentedon Aug 23, 2022
I computed the incidence signal a third way on this same dataset, using Pandas groupby and diff, and found that the JIT code had no differences, while the live code had the same list as above.
dshemetov commentedon Aug 24, 2022
Ok, now this is very strange:
So the API has different data from what the indicator output CSV files contain.
So something might be wrong with the archiver??? 👀 Either:
dshemetov commentedon Aug 25, 2022
I used the county 02100 data above and tested the archiver on the incidence data (created a before file with
02100 20200624 0.0and an after file with02100 20200624 2.0to make sure the diff is detected). The diff is correctly found, see #1687.dshemetov commentedon Aug 25, 2022
Alright, so at least one instance of cache desync confirmed:
So the cache thinks the DB already has the latest value in its latest issue, whereas it actually doesn't, so no update occurs to the new value.
I guess I'll download the full S3 cache, download the full API dataset, and see how many values are in this situation.
krivard commentedon Aug 26, 2022
Nice work identifying that example! Looping in @neul3 as he's growing more familiar with debugging these kinds of issues using the DB.
The database records show at least one additional problem, and that is a misfiled is_latest_issue flag:
What seems to have happened is:
is_latest_issuefor this geo-temporal point at issue 20210927.is_latest_issuebut, for whatever reason, did not.The immediate solution in v3 would be to find a quiet afternoon and run an exhaustive
is_latest_issuerepair, because if this happened once, it probably has happened multiple times. With the v4 rollout, there was half a chance the data migration would have fixed this particular fault automatically when splitting data between the latest and history tables, but alas it looks like the migration routine treated theis_latest_issueflags as authoritative as a time-saving measure. We'll need to adapt the old v3 is-latest repair routines for v4.The upside is that the cache didn't lose sync, at least not in this instance. Is it possible to adapt your evaluation script to double-check that what's being reported as the latest issue doesn't have a sneaky more-recent sibling? Something like
might do it.
dshemetov commentedon Aug 26, 2022
Good find on the
is_latest_issueproblem! And thanks for that code (didn't know you could pass a range to issue)!dshemetov commentedon Aug 29, 2022
A summary of work done today with @nolangormley:
is_latest_issueflagsis_latest_issue=1rows withsignal=confirmed_incidence_numsandgeo_type=state, we had ~5k rows where there was a more recent issue availabletime_valueprior to 20211020, suggesting that this is due to left over bugs with the patch that went out at that time (and not a persisting problem with indicators or another part of the pipeline)Next steps:
is_latest_issueand get a breakdown of these by (signal, geo)SELECT * FROM covidcast c JOIN (SELECT source, signal, geo_type, geo_value, time_type, time_value, issue latest_issue FROM covidcast t WHERE is_latest_issue=1) x USING (source, signal, geo_type, geo_value, time_type, time_value) WHERE issue>=latest_issue(source, signal, geo_type, geo_value, time_type, time_value, issue, is_latest_issue)fieldsNext steps for JIT:
krivard commentedon Sep 28, 2022
Patch is in! Spot check:
@dshemetov can you see if there are any remaining bad values in jhu-csse?
nolangormley commentedon Sep 29, 2022
I believe the next steps here -- as laid out by Dmitry above -- is to check the archive differ s3 bucket to ensure that our cache is in sync
dshemetov commentedon Oct 6, 2022
Took a quick look in JIT comparisons of derived signals and patched JHU data was free of cache sync issues.
krivard commentedon Oct 7, 2022
🥳