yang
This project has not described itself yet.
Brought by drakestapleton
yang / scripts / search_open_collars.py
| 1 | """Finite search over backgrounds for the influence of one boundary link.""" |
| 2 | from concurrent.futures import ProcessPoolExecutor |
| 3 | from statistics import fmean |
| 4 | import argparse |
| 5 | from probe_open_collar import Box |
| 6 | |
| 7 | |
| 8 | def run(job): |
| 9 | collar, seed = job |
| 10 | return collar, seed, Box(4).pair(2.3, seed, 64, 128, False, collar) |
| 11 | |
| 12 | |
| 13 | def main(): |
| 14 | p = argparse.ArgumentParser(description=__doc__) |
| 15 | p.add_argument("--workers", type=int, default=1) |
| 16 | args = p.parse_args() |
| 17 | candidates = ("identity", "sheet", "rough") |
| 18 | with ProcessPoolExecutor(max_workers=args.workers) as pool: |
| 19 | train = list(pool.map(run, ((c, s) for c in candidates for s in range(70, 74)))) |
| 20 | winner = max(candidates, key=lambda c: abs(fmean(v[2] for name, _, v in train if name == c))) |
| 21 | hold = list(pool.map(run, ((winner, s) for s in range(80, 88)))) |
| 22 | print("stage", "collar", "seed", "P_base", "P_changed", "signed_change", "absolute_change", sep="\t") |
| 23 | for phase, rows in (("train", train), ("heldout", hold)): |
| 24 | for name, seed, values in rows: |
| 25 | print(phase, name, seed, *(f"{x:.12g}" for x in values), sep="\t") |
| 26 | |
| 27 | |
| 28 | if __name__ == "__main__": |
| 29 | main() |