washingtonpost / elex-live-model

a model to generate estimates of the number of outstanding votes on an election night based on the current results of the race
48 stars 5 forks source link

Elex 4455 add race call contest agg #101

Closed lennybronner closed 1 month ago

lennybronner commented 1 month ago

Description

We move the race calling from get_national_summary to get_aggregate_predictions and get_aggregate_prediction_intervals. This means that we apply the race calls to the contest level predictions also (ie. state predictions or house district predictions) instead of purely on the national summary predictions.

This is more conceptually correct, but will also let us show the our contest level predictions after race calls have already happened if we want.

Unit tests were also updated to take this into account.

Jira Ticket

https://arcpublishing.atlassian.net/browse/ELEX-4455

Test Steps

elexmodel 2017-11-07_VA_G --estimands=margin --office_id=G --geographic_unit_type=county --pi_method bootstrap --features baseline_normalized_margin --called_contests='{"VA": 0}' --percent_reporting 10 --aggregates postal_code --aggregates county_classification

This now allows a force call for Republicans (and you can see the predictions and intervals all be below zero for the state as a result).

If you want to test on aggregate model, then you can just add more contests using this dictionary (either in the CLI or using the testbed).

{'VA-47': 0, 'VA-50': 0, 'VA-51': 0, 'VA-53': 0, 'VA-55': 1, 'VA-61': 0, 'VA-62': 0, 'VA-89': 0, 'VA-64': 0, 'VA-65': 1, 'VA-66': 0, 'VA-70': 1, 'VA-71': 0, 'VA-73': 0, 'VA-75': 0, 'VA-82': -1, 'VA-60': 0, 'VA-76': 1, 'VA-83': 0, 'VA-84': 1, 'VA-41': -1, 'VA-33': 0, 'VA-86': 0, 'VA-87': 1, 'VA-88': 1, 'VA-90': 0, 'VA-93': 1, 'VA-94': 1, 'VA-96': 1, 'VA-34': 0, 'VA-97': 1, 'VA-99': 0, 'VA-72': 0, 'VA-31': 0, 'VA-11': 1, 'VA-30': 0, 'VA-52': 0, 'VA-91': 1, 'VA-92': 1, 'VA-100': 0, 'VA-6': 1, 'VA-7': 1, 'VA-8': 1, 'VA-9': 1, 'VA-10': 1, 'VA-14': 1, 'VA-15': 1, 'VA-18': 1, 'VA-21': -1, 'VA-32': 0, 'VA-36': 0, 'VA-37': 0, 'VA-40': 0, 'VA-57': 0, 'VA-58': 1, 'VA-59': 0, 'VA-23': 1, 'VA-20': 1, 'VA-22': 0, 'VA-25': 1, 'VA-26': 1, 'VA-27': 1, 'VA-28': 1, 'VA-29': 1, 'VA-67': 0}

also pytest

jjcherian commented 1 month ago

LGTM.