Skip to content
Permalink
Browse files

more handling of "none" cases

  • Loading branch information...
matthewcornell committed Oct 3, 2019
1 parent a13c08d commit 432d81df7d16f5c8a2a764057f81950ad4f4f657
@@ -1,6 +1,7 @@
"Location","Target","Type","Unit","Bin_start_incl","Bin_end_notincl","Value"
"US National","Season onset","Point","week",NA,NA,50
"US National","Season onset","Bin","week","40","41",1
"US National","Season onset","Bin","week","40","41",0.9
"US National","Season onset","Bin","week","none","none",0.1
"US National","Season peak week","Point","week",NA,NA,5
"US National","Season peak week","Bin","week","40","41",1
"US National","Season peak percentage","Point","percent",NA,NA,3.9
@@ -4,11 +4,11 @@
{"location": "HHS Region 1", "target": "1 wk ahead", "class": "Point", "prediction": {"value": 3}},
{"location": "HHS Region 1", "target": "2 wk ahead", "class": "BinLwr", "prediction": {"lwr": [0.0, 0.1], "prob": [4.0, 5.0]}},
{"location": "HHS Region 1", "target": "2 wk ahead", "class": "Point", "prediction": {"value": 6}},
{"location": "HHS Region 10", "target": "Season onset", "class": "BinCat", "prediction": {"cat": ["1", "10", "None"], "prob": [7.0, 8.0, 9.0]}},
{"location": "HHS Region 10", "target": "Season onset", "class": "BinCat", "prediction": {"cat": ["1", "10", "none"], "prob": [7.0, 8.0, 9.0]}},
{"location": "HHS Region 10", "target": "Season onset", "class": "Point", "prediction": {"value": "10"}},
{"location": "HHS Region 10", "target": "Season peak percentage", "class": "BinLwr", "prediction": {"lwr": [0.0], "prob": [11.0]}},
{"location": "HHS Region 10", "target": "Season peak percentage", "class": "Point", "prediction": {"value": 12}},
{"location": "US National", "target": "Season peak week", "class": "BinCat", "prediction": {"cat": ["1", "10", "11"], "prob": [13.0, 14.0, 15.0]}},
{"location": "US National", "target": "Season peak week", "class": "Point", "prediction": {"value": "None"}}
{"location": "US National", "target": "Season peak week", "class": "Point", "prediction": {"value": "none"}}
]
}
@@ -14,4 +14,4 @@ HHS Region 10,Season peak percentage,Point,percent,NA,NA,12
US National,Season peak week,Bin,week,1,2,13
US National,Season peak week,Bin,week,10,11,14
US National,Season peak week,Bin,week,11,12,15
US National,Season peak week,Point,week,NA,NA,None
US National,Season peak week,Point,week,NA,NA,none
@@ -1561,10 +1561,12 @@
"class": "BinCat",
"prediction": {
"cat": [
"40"
"40",
"none"
],
"prob": [
1.0
0.9,
0.1
]
}
},
@@ -274,7 +274,7 @@ def test_forecast_data_and_accessors(self):
.values_list('location__name', 'target__name', 'cat', 'prob')
self.assertEqual(737, bincat_distribution_qs.count())
self.assertEqual(('HHS Region 1', 'Season onset', '1', 2.37797107673309e-05), bincat_distribution_qs[0])
self.assertEqual(('HHS Region 1', 'Season onset', 'None', 0.0227300694570138), bincat_distribution_qs[33])
self.assertEqual(('HHS Region 1', 'Season onset', 'none', 0.0227300694570138), bincat_distribution_qs[33])


def test_forecast_delete(self):
@@ -91,7 +91,7 @@ def test_load_predictions_from_cdc_csv_file(self):
with open(self.cdc_csv_path) as cdc_csv_fp:
json_io_dict = json_io_dict_from_cdc_csv_file(cdc_csv_fp)
load_predictions_from_json_io_dict(self.forecast, json_io_dict)
self.assertEqual(22, self.forecast.bincat_distribution_qs().count())
self.assertEqual(23, self.forecast.bincat_distribution_qs().count())
self.assertEqual(55, self.forecast.binlwr_distribution_qs().count())
self.assertEqual(0, self.forecast.binary_distribution_qs().count())
self.assertEqual(0, self.forecast.named_distribution_qs().count())
@@ -174,11 +174,12 @@ def _prediction_dicts_for_csv_rows(rows):
try:
if is_point_row:
# NB: point comes in as a number (see parse_value() below), but should be a string
# for Targets whose point_value_type is Target.POINT_TEXT
point_value = str(value) if target_name in BINCAT_TARGET_NAMES else value
# for Targets whose point_value_type is Target.POINT_TEXT. lower() handles 'None' -> 'none'
point_value = str(value).lower() if target_name in BINCAT_TARGET_NAMES else value
point_values.append(point_value)
elif target_name in BINCAT_TARGET_NAMES:
bincat_cats.append(str(bin_start_incl))
bin_start_incl_value = str(bin_start_incl) if target_name in BINCAT_TARGET_NAMES else bin_start_incl
bincat_cats.append(bin_start_incl_value.lower()) # lower() ""
bincat_probs.append(float(value))
elif target_name in BINLWR_TARGET_NAMES:
binlwr_lwrs.append(float(bin_start_incl))

0 comments on commit 432d81d

Please sign in to comment.
You can’t perform that action at this time.