Skip to content
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

Elex 4455 add race call contest agg #101

Merged
merged 24 commits into from
Sep 9, 2024

Conversation

lennybronner
Copy link
Collaborator

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

@lennybronner lennybronner requested a review from a team as a code owner September 4, 2024 01:46
@dmnapolitano dmnapolitano self-assigned this Sep 4, 2024
src/elexmodel/cli.py Show resolved Hide resolved
src/elexmodel/models/BootstrapElectionModel.py Outdated Show resolved Hide resolved
src/elexmodel/models/BootstrapElectionModel.py Outdated Show resolved Hide resolved
tests/models/test_bootstrap_election_model.py Show resolved Hide resolved
Copy link
Contributor

@dmnapolitano dmnapolitano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for answering all my weird questions! 😄 🎉 🎉

@jjcherian
Copy link
Collaborator

LGTM.

@lennybronner lennybronner merged commit 63e8aa1 into develop Sep 9, 2024
3 checks passed
@lennybronner lennybronner deleted the elex-4455-add-race-call-contest-agg branch September 9, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants