sklearn.model_selection.ParameterGrid?
class sklearn.model_selection.ParameterGrid(param_grid)
[源碼]
網格的參數,每個網格都有離散數量的值。
可用于通過Python內置函數iter遍歷參數值組合。
在用戶指南中閱讀更多內容。
參數 | 說明 |
---|---|
param_grid | dict of str to sequence, or sequence of such 要探索的參數網格,作為將估計器參數映射到允許值序列的字典。 空字典表示默認參數。 字典序列表示要搜索的網格序列,對于避免探索毫無意義或沒有效果的參數組合很有用。請參閱下面的示例。 |
另見:
GridSearchCV
用于ParameterGrid
執行完整的并行化參數搜索。
示例
>>> from sklearn.model_selection import ParameterGrid
>>> param_grid = {'a': [1, 2], 'b': [True, False]}
>>> list(ParameterGrid(param_grid)) == (
... [{'a': 1, 'b': True}, {'a': 1, 'b': False},
... {'a': 2, 'b': True}, {'a': 2, 'b': False}])
True
>>> grid = [{'kernel': ['linear']}, {'kernel': ['rbf'], 'gamma': [1, 10]}]
>>> list(ParameterGrid(grid)) == [{'kernel': 'linear'},
... {'kernel': 'rbf', 'gamma': 1},
... {'kernel': 'rbf', 'gamma': 10}]
True
>>> ParameterGrid(grid)[1] == {'kernel': 'rbf', 'gamma': 1}
True
__init__(self,param_grid )
[源碼]
初始化self。詳情可參閱 type(self)的幫助。