Created
March 1, 2021 15:13
-
-
Save theorm/9eceb6968ad4ee679da27f2121ecf43a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
def dict_product(dicts): | |
""" | |
Cartesian product. | |
See https://stackoverflow.com/questions/5228158/cartesian-product-of-a-dictionary-of-lists | |
>>> list(dict_product(dict(number=[1,2], character='ab'))) | |
[{'character': 'a', 'number': 1}, | |
{'character': 'a', 'number': 2}, | |
{'character': 'b', 'number': 1}, | |
{'character': 'b', 'number': 2}] | |
""" | |
return (dict(zip(dicts, x)) for x in itertools.product(*dicts.values())) | |
parameters = { | |
'min_count': [1,2,3], | |
'size': [5,6,7], | |
'seed': [1], | |
# other parameters in the format above | |
} | |
for parameters_set in dict_product(parameters): | |
print('Running experiment with parameters set: ', parameters_set) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment