Skip to content

Commit

Permalink
Merge pull request #102 from washingtonpost/elex-4465-replace-point-p…
Browse files Browse the repository at this point in the history
…rediction-with-bootstrap-mean

replace point pred with bootstrap mean
  • Loading branch information
lennybronner authored Sep 9, 2024
2 parents 6d60433 + 919a08c commit 5569c56
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/elexmodel/models/BootstrapElectionModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,14 +960,10 @@ def compute_bootstrap_errors(
# \tilde{y_i}^{b} * \tilde{z_i}^{b}
yz_test_pred_B = y_test_pred_B * z_test_pred_B

# In order to generate our point prediction, we also need to apply our non-bootstrapped model to the testset
# In order to generate our point prediction, we take the bootstrap mean.
# this is \hat{y_i} and \hat{z_i}
y_test_pred = (ols_y.predict(x_test) + (aggregate_indicator_test @ epsilon_y_hat)).clip(
min=y_partial_reporting_lower, max=y_partial_reporting_upper
)
z_test_pred = (ols_z.predict(x_test) + (aggregate_indicator_test @ epsilon_z_hat)).clip(
min=z_partial_reporting_lower, max=z_partial_reporting_upper
)
y_test_pred = y_test_pred_B.mean(axis=1).reshape(-1, 1)
z_test_pred = z_test_pred_B.mean(axis=1).reshape(-1, 1)
yz_test_pred = y_test_pred * z_test_pred

# we now need to generate our bootstrapped "true" quantities (in order to subtract the
Expand Down

0 comments on commit 5569c56

Please sign in to comment.