We evaluate our approach and analyze the following four data sets:
- Swiss referenda (326 referenda with binary outcome)
- Popular vote of US presidential elections (binary outcomes between the Democrat and Republican candidates)
- State-level German legislative elections (for the 5 major parties)
- District-level (Wahlkreise) German legislative elections (for the 5 major parties)
These datasets are located in the data.
To reproduce the results and figures of the paper, simply run the script scripts/test.sh:
sh scripts/test.shThis will train the model on all but the last vote (either referendum or election depending on the dataset), and it will evaluate on the last vote using the best hyperparameters we reported.
Each experiment is split into three steps:
- We run a grid search for the hyperparameters on historical data (
run_benchmark.py --models train). - We select the best hyperparameters (
evaluate_benchmark.py). - We evaluate the models using the best hyperparameters (
run_benchmark.py --models test).
For Step 1, the ranges of hyperparameters are specified directly in run_benchmark.py (see get_models() on lines 47-76). the arguments to run_benchmark.py` are as follows:
The arguments are as follows:
--nameis the filename of the results--data_diris the directory for the dataset--n_obsis the number of observed (historical) votes--v_maxis the last vote for which we make predictions--modelsis either train or test to select which procedure to run--datasetis one of CH, US, DEState, DELocal--n_ordersis the number of randomized reveal-orders of regional results--n_quantilescontrols at how many discrete points performance is measured--logscaleenables selection of the discrete point on a logarithmic scale For example, we run the following command the select the hyperparameters for the Swiss referenda dataset:
python run_benchmark.py --name trainCH --data_dir ../data/ --n_obs 275 --v_max 300 --models train --dataset CH --n_orders 10 --n_quantiles 50 --logscaleFor Step 2, we run the following command to evaluate the results of the experiments to select the best hyperparameters:
python evaluate_benchmark.py --name trainCHThis will display the mean absolute errors for each model.
Here, --name should be the same as --name from Step 1.
We select the best combination of hyperparameters, and we add them to run_benchmark.py (see get_models() on lines 15-45)
Finally, for Step 3, we evaluate the model on a test set using the best hyperparameters from Step 2 using: Then, we are ready to run the final benchmark using
python run_benchmark.py --name testCH --data_dir ../data/ --n_obs 300 --v_max 326 --models test --dataset CH --n_orders 100 --n_quantiles 50 --logscaleIn short, to reproduce all results:
- Run
scripts/train.sh - Run
python evaluate_benchmark.py --name NAMEon all resulting files - Optionally adjust the test models in
run_benchmark.py - Run
scripts/test.sh.