create_grid_params
- czsc.create_grid_params(prefix: str = '', multiply=3, **kwargs) dict [source]
创建 grid search 参数组合
- Parameters:
prefix – 参数组前缀
multiply – 参数组合的位数,如果为 0,则使用 # 分隔参数
kwargs – 任意参数的候选序列,参数值推荐使用 iterable
- Returns:
参数组合字典
Examples
>>>x = create_grid_params(“test”, x=(1, 2), y=(‘a’, ‘b’), detail=True) >>>print(x) Out[0]:
- {‘test_x=1_y=a’: {‘x’: 1, ‘y’: ‘a’},
‘test_x=1_y=b’: {‘x’: 1, ‘y’: ‘b’}, ‘test_x=2_y=a’: {‘x’: 2, ‘y’: ‘a’}, ‘test_x=2_y=b’: {‘x’: 2, ‘y’: ‘b’}}
# 单个参数传入单个值也是可以的,但类型必须是 int, float, str 中的任一 >>>x = create_grid_params(“test”, x=2, y=(‘a’, ‘b’), detail=False) >>>print(x) Out[1]:
- {‘test001’: {‘x’: 2, ‘y’: ‘a’},
‘test002’: {‘x’: 2, ‘y’: ‘b’}}