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 2766 separate out conformalization models #72

Closed lennybronner closed 1 year ago

lennybronner commented 1 year ago

Description

In order to prepare for the Bootstrap model (which does not use conformalization), I had to change the inheritance structure of our models so far. We now have a ConformalElectionModel which inherits from the BaseElectionModel and the GaussianElectionModel and NonparametricElectionModel inherit from that. This means we can re-use the aggregation code from the BaseElectionModel in the upcoming bootstrap model without running into issues with a non-existent conformalization set.

We now only deal with the conformalization data in the client if we are using a ConformalElectionModel rather than always, which is what we were doing previously.

I also added type hints and updated the unit tests correspondingly.

Jira Ticket

elex-2766

Test Steps

Unit tests are updated, so tox works.

Also both old models work like normal:

elexmodel 2020-11-03_USA_G --office_id=P --estimands=dem --geographic_unit_type=county --pi_method=gaussian --percent_reporting=20 --model_parameters="{'lambda_': 1, 'beta': 4, 'winsorize': True}" --aggregates=postal_code --aggregates=county_classification --aggregates=unit

and

elexmodel 2020-11-03_USA_G --office_id=P --estimands=dem --geographic_unit_type=county --pi_method=nonparametric --percent_reporting=20 --model_parameters="{'lambda_': 1, 'robust': True}"
lennybronner commented 1 year ago

A couple of questions and suggestions but otherwise, I think this looks great! 🎉

Ok, I updated the two new models into abstract base classes and added/updated/moved unit tests correspondingly!