]> code.communitydata.science - ml_measurement_error_public.git/blob - simulations/grid_sweep.py
changes from klone
[ml_measurement_error_public.git] / simulations / grid_sweep.py
1 #!/usr/bin/env python3
2
3 import fire
4 from itertools import product
5 import pyRemembeR
6
7 def main(command, arg_dict, outfile, remember_file='remember_grid_sweep.RDS'):
8     print(remember_file)
9     remember = pyRemembeR.remember.Remember()
10     remember.set_file(remember_file)
11     remember[outfile] = arg_dict
12     remember.save_to_r()
13     keys = []
14     values = []
15         
16     for i,p in enumerate(arg_dict.items()):
17         k,v = p
18         keys.append(k)
19         values.append(v)
20         command = command + f" --{k} {{{i}}} "
21
22     args_list = product(*values)
23
24     with open(outfile,'w') as of:
25         for args in args_list:
26             of.write(command.format(*args) + '\n')
27
28 if __name__ == '__main__':
29     fire.Fire(main)

Community Data Science Collective || Want to submit a patch?