Skip to content

Commit 8fd7356

Browse files
committed
Updating with new dataset for 2021-11-09
1 parent 3f8922f commit 8fd7356

9 files changed

Lines changed: 10170 additions & 4 deletions

R/review_public.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ quasi_identifiers = c("race_ethnicity_combined","sex","age_group")
2626
confidential_attributes = c("pos_spec_dt")
2727

2828
#if I use a CSV then there's logic to change down below
29-
file_name <- "COVID_Cases_Public_Limited_20211012.parquet"
29+
file_name <- "COVID_Cases_Public_Limited_20211109.parquet"
3030
#file_name <- "github_test.csv"
3131

3232
suppressed_file_name = paste(out_dir,"/",file_name,".suppressed.csv",sep="")

R/review_public_geo.R

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ linked_attributes = list(
5050
)
5151

5252
#if I use a CSV then there's logic to change down below
53-
file_name <- "public_county_geography_2021-08-03.parquet"
53+
file_name <- "public_county_geography_2021-11-09.parquet"
5454
suppressed_file_name = paste(out_dir,"/",file_name,".suppressed.csv",sep="")
5555
detailed_file_name = paste(data_dir,"/",file_name,sep="")
5656
print(detailed_file_name)
@@ -61,6 +61,10 @@ df = read_parquet(detailed_file_name, as_data_frame = TRUE)
6161
#for some reason the dataframe from arrow makes sdc take forever and error, but if I make a new dataframe it works, todo figure it out
6262
data <- data.frame(df)
6363

64+
save(df, file = "Geo_df.Rdata")
65+
remove(df)
66+
67+
6468
#summarize dataset
6569
result <- quick_summary(data, label="all_fields", qis=quasi_identifiers)
6670

@@ -125,18 +129,24 @@ cat("\n\nWriting out a privacy eval report to:", paste(report_dir,"/",file_name,
125129
report(sdcObj, outdir = report_dir, filename = file_name,
126130
title = "SRRG Privacy Evaluation Report for Case Surveillance Public Data Set with Geography", internal = TRUE, verbose = FALSE)
127131

132+
save(sdcObj, file = "Geo_sdcObj.Rdata")
133+
remove(sdcObj)
134+
135+
save(data, file = "Geo_data.Rdata")
136+
remove(data)
137+
128138
cat('Processing check for low population counties (rule #3), should be 0.\n')
129139

130140
#weird way to read in a file to support utf characters in dataset #TODO fix
131141
fileIn=file(COUNTY_POP_FILE_NAME,open="rb",encoding="UTF-8-BOM")
132142
lines = readLines(fileIn)
133-
county_data = read.csv(text=lines, na.strings=c('NA',''), colClasses=c("state_county_combined_fips"="character"))
143+
county_data = read.csv(text=lines, na.strings=c('NA',''), colClasses=c("ï..state_county_combined_fips"="character"))
134144

135145
#county_data = read.csv(COUNTY_POP_FILE_NAME, fileEncoding="UTF-8-BOM", na.strings=c('NA',''),colClasses=c("state_county_combined_fips"="character"))
146+
names(county_data)[names(county_data) == 'ï..state_county_combined_fips'] <- 'county_fips_code'
136147
names(county_data)[names(county_data) == 'state_county_combined_fips'] <- 'county_fips_code'
137148
names(county_data) <- tolower(names(county_data))
138149
county_data['state_abbr'] = state.abb[match(county_data$stname,state.name)]
139-
140150
data_with_census = merge(x=data_na, y=county_data, by = 'county_fips_code', all.x = TRUE)
141151

142152
#if I screw up the merge, that's bad
@@ -153,6 +163,9 @@ if (num_v > 0){
153163
print(violations[sample(num_v,min(num_v,5)),c(quasi_identifiers, 'sum_of_tot_pop')])
154164
}
155165

166+
save(data_na, file = "Geo_data_na.Rdata")
167+
remove(data_na)
168+
156169
#basically my logic here for rule #4 is that any county's population by sex, race, and/or ethnicity should be greater than or equal to 220. So I'll check each record that's not NA
157170
cat('\n\nProcessing check for low subpopulation demographics in counties (rule #4), should be 0, twice.\n')
158171

@@ -202,6 +215,11 @@ if (num_v > 0){
202215
print(violations[sample(num_v,min(num_v,5)),])
203216
}
204217

218+
save(data_with_census_case, file = "Geo_data_with_census_case.Rdata")
219+
remove(data_with_census_case)
220+
221+
load(file = "Geo_data.Rdata")
222+
205223
cat('\n\nProcessing check for county/state complementary offsets (rule #10), should be 0.\n')
206224

207225
census_counties_per_state = aggregate(data=county_data, ctyname ~ state_abbr, function(x) length(unique(x)))
4.06 KB
Binary file not shown.
3.65 KB
Binary file not shown.

reports/COVID_Cases_Public_Limited_20211109.parquet.html

Lines changed: 436 additions & 0 deletions
Large diffs are not rendered by default.

reports/COVID_Cases_Public_Limited_20211109_parquet_profile.html

Lines changed: 1643 additions & 0 deletions
Large diffs are not rendered by default.

reports/log.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,3 +2708,131 @@ checking l-diversity manually for < pos_spec_dt >, found < 0 > l-diversity viola
27082708
<0 rows> (or 0-length row.names)
27092709
27102710
```
2711+
2712+
## 2020-10-25
2713+
2714+
[DataExplorer Profile Report](../reports/COVID_Cases_Public_Limited_2021-10-25_parquet_profile.html)
2715+
2716+
```
2717+
[1] "C:/Users/rwe4/OneDrive - CDC/R_projects/covid_case_privacy_review/R"
2718+
2719+
[1] "Quick summary:"
2720+
all_fields quasi_fields
2721+
total_fields 12 3
2722+
total_records 35,638,780 35,638,780
2723+
total_cells 427,665,360 106,916,340
2724+
missing_fields 86,949,327 1,273,443
2725+
missing_pct 20% 1%
2726+
complete_fields 340,716,033 105,642,897
2727+
complete_pct 80% 99%
2728+
unknown_fields 27,947,596 11,608,609
2729+
unknown_pct 7% 11%
2730+
suppressed_fields 103 103
2731+
suppressed_pct 0% 0%
2732+
available_fields 312,768,334 94,034,185
2733+
available_pct 73% 88%
2734+
2735+
Utility summary:
2736+
Total records in dataset: 35,638,780
2737+
suppressed suppressed_percent missing missing_percent
2738+
race_ethnicity_combined 12 0.0% 832,461 2.3%
2739+
sex 18 0.0% 74,860 0.2%
2740+
age_group 73 0.0% 366,122 1.0%
2741+
records_with_any_field 73 0.0% 1,182,996 3.3%
2742+
2743+
SDC summary for k-anon-level( 5 ).
2744+
The input dataset consists of 35638780 rows and 12 variables.
2745+
--> Categorical key variables: race_ethnicity_combined, sex, age_group
2746+
----------------------------------------------------------------------
2747+
2748+
2749+
Information on categorical key variables:
2750+
2751+
Reported is the number, mean size and size of the smallest category >0 for recoded variables.
2752+
In parenthesis, the same statistics are shown for the unmodified data.
2753+
Note: NA (missings) are counted as seperate categories!
2754+
2755+
2756+
Key Variable Number of categories Mean size Size of smallest (>0)
2757+
race_ethnicity_combined 8 (8) 3357568.286 (3357568.286) 68000 (68000)
2758+
sex 4 (4) 11752874.000 (11752874.000) 705 (705)
2759+
age_group 10 (10) 3919176.111 (3919176.111) 1222842 (1222842)
2760+
----------------------------------------------------------------------
2761+
2762+
2763+
Risk measures:
2764+
2765+
Number of observations with higher risk than the main part of the data: 104
2766+
Expected number of re-identifications: 161.53 (0.00 %)
2767+
2768+
k-anon violations ( 0 ) for k=( 5 ) and quasi-identifiers ( race_ethnicity_combined sex age_group ). If greater than zero violations, then here's 5 violations.
2769+
2770+
checking l-diversity manually for < pos_spec_dt >, found < 0 > l-diversity violations.
2771+
[1] race_ethnicity_combined sex age_group pos_spec_dt
2772+
[5] fk ldiv
2773+
<0 rows> (or 0-length row.names)
2774+
```
2775+
2776+
## 2021-11-09
2777+
2778+
[DataExplorer Profile Report](../reports/COVID_Cases_Public_Limited_2021-11-09_parquet_profile.html)
2779+
2780+
```
2781+
[1] "C:/Users/rwe4/OneDrive - CDC/R_projects/covid_case_privacy_review/R"
2782+
2783+
[1] "Quick summary:"
2784+
all_fields quasi_fields
2785+
total_fields 12 3
2786+
total_records 37,532,072 37,532,072
2787+
total_cells 450,384,864 112,596,216
2788+
missing_fields 96,399,423 1,323,719
2789+
missing_pct 21% 1%
2790+
complete_fields 353,985,441 111,272,497
2791+
complete_pct 79% 99%
2792+
unknown_fields 29,121,517 12,249,731
2793+
unknown_pct 6% 11%
2794+
suppressed_fields 108 108
2795+
suppressed_pct 0% 0%
2796+
available_fields 324,863,816 99,022,658
2797+
available_pct 72% 88%
2798+
2799+
Utility summary:
2800+
Total records in dataset: 37,532,072
2801+
suppressed suppressed_percent missing missing_percent
2802+
race_ethnicity_combined 13 0.0% 875,896 2.3%
2803+
sex 19 0.0% 76,966 0.2%
2804+
age_group 76 0.0% 370,857 1.0%
2805+
records_with_any_field 76 0.0% 1,232,005 3.3%
2806+
2807+
SDC summary for k-anon-level( 5 ).
2808+
The input dataset consists of 37532072 rows and 12 variables.
2809+
--> Categorical key variables: race_ethnicity_combined, sex, age_group
2810+
----------------------------------------------------------------------
2811+
2812+
2813+
Information on categorical key variables:
2814+
2815+
Reported is the number, mean size and size of the smallest category >0 for recoded variables.
2816+
In parenthesis, the same statistics are shown for the unmodified data.
2817+
Note: NA (missings) are counted as seperate categories!
2818+
2819+
2820+
Key Variable Number of categories Mean size Size of smallest (>0)
2821+
race_ethnicity_combined 8 (8) 3532905.429 (3532905.429) 70494 (70494)
2822+
sex 4 (4) 12377060.333 (12377060.333) 754 (754)
2823+
age_group 10 (10) 4129015.444 (4129015.444) 1287049 (1287049)
2824+
----------------------------------------------------------------------
2825+
2826+
2827+
Risk measures:
2828+
2829+
Number of observations with higher risk than the main part of the data: 114
2830+
Expected number of re-identifications: 161.66 (0.00 %)
2831+
2832+
k-anon violations ( 0 ) for k=( 5 ) and quasi-identifiers ( race_ethnicity_combined sex age_group ). If greater than zero violations, then here's 5 violations.
2833+
2834+
checking l-diversity manually for < pos_spec_dt >, found < 0 > l-diversity violations.
2835+
[1] race_ethnicity_combined sex age_group pos_spec_dt
2836+
[5] fk ldiv
2837+
<0 rows> (or 0-length row.names)
2838+
'''

reports/public_county_geography_2021-11-09.parquet.html

Lines changed: 6284 additions & 0 deletions
Large diffs are not rendered by default.

reports/public_county_geography_2021-11-09_profile.html

Lines changed: 1657 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)