How to use 'grid search python' in Python

Every line of 'grid search python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
44def grid_search(script: str, params: typing.Iterable[str], dry_run: bool=False) -> None:
45 """
46 Build all grid search parameter configurations and optionally run them.
47
48 :param script: String of command prefix, e.g. ``cxflow train -v -o log``.
49 :param params: Iterable collection of strings in standard cxflow param form, e.g. ``'numerical_param:int=[1, 2]'``
50 or ``'text_param:str=["hello", "cio"]'``.
51 :param dry_run: If set to ``True``, the built commands will only be printed instead of executed.
52 """
53
54 commands = _build_grid_search_commands(script=script, params=params)
55
56 if dry_run:
57 logging.warning('Dry run')
58 for command in commands:
59 logging.info(command)
60 else:
61 for command in commands:
62 try:
63 completed_process = subprocess.run(command)
64 logging.info('Command `%s` completed with exit code %d', command, completed_process.returncode)
65 except Exception as _: # pylint: disable=broad-except
66 logging.error('Command `%s` failed.', command)

Related snippets