本文整理汇总了Python中sklearn.grid_search.ParameterGrid方法的典型用法代码示例。如果您正苦于以下问题:Python grid_search.ParameterGrid方法的具体用法?Python grid_search.ParameterGrid怎么用?Python grid_search.ParameterGrid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.grid_search
的用法示例。
在下文中一共展示了grid_search.ParameterGrid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cross_validate
# 需要导入模块: from sklearn import grid_search [as 别名]
# 或者: from sklearn.grid_search import ParameterGrid [as 别名]
def cross_validate(self, X, y):
print "fitting {} to the training set".format(self.name)
if self.param_grid is not None:
param_sets = list(ParameterGrid(self.param_grid))
n_param_sets = len(param_sets)
param_scores = []
for j, param_set in enumerate(param_sets):
print "--------------"
print "training the classifier..."
print "parameter set:"
for k, v in param_set.iteritems():
print "{}:{}".format(k, v)
param_score = self.evaluate(X, y, param_set=param_set)
param_scores.append(param_score)
p = np.argmax(np.array(param_scores))
self.best_param_set = param_sets[p]
print "best parameter set", self.best_param_set
print "best score:", param_scores[p]
else:
score = self.evaluate(X, y)
示例2: fit
# 需要导入模块: from sklearn import grid_search [as 别名]
# 或者: from sklearn.grid_search import ParameterGrid [as 别名]
def fit(self, X, y=None):
"""Run fit with all sets of parameters.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples is the number of samples and
n_features is the number of features.
y : array-like, shape = [n_samples] or [n_samples, n_output], optional
Target relative to X for classification or regression;
None for unsupervised learning.
"""
return self._fit(X, y, ParameterGrid(self.param_grid))
示例3: fit
# 需要导入模块: from sklearn import grid_search [as 别名]
# 或者: from sklearn.grid_search import ParameterGrid [as 别名]
def fit(self, frame):
"""Fit the grid search.
Parameters
----------
frame : H2OFrame, shape=(n_samples, n_features)
The training frame on which to fit.
"""
return self._fit(frame, ParameterGrid(self.param_grid))
示例4: create_misc_confs
# 需要导入模块: from sklearn import grid_search [as 别名]
# 或者: from sklearn.grid_search import ParameterGrid [as 别名]
def create_misc_confs():
from sklearn.grid_search import ParameterGrid
params = {'break_width': [1.5, 2.0, 3.6, 5.0],
'recognizer': ['probout', 'hmm'], 'combine_hangoff': [.4, .6, .8],
'postprocess': [True, False], 'segmenter': ['experimental', 'stochastic'],
'line_cluster_pos': ['top', 'center'],
}
grid = ParameterGrid(params)
for pr in grid:
Config(save_conf=True, **pr)
示例5: __get_param_iterable
# 需要导入模块: from sklearn import grid_search [as 别名]
# 或者: from sklearn.grid_search import ParameterGrid [as 别名]
def __get_param_iterable(self, param_grid):
if self.ramdonized_search_enable:
parameter_iterable = ParameterSampler(param_grid,
self.randomized_search_n_iter,
random_state=self.ramdonized_search_random_state)
else:
parameter_iterable = ParameterGrid(param_grid)
return parameter_iterable
示例6: fit
# 需要导入模块: from sklearn import grid_search [as 别名]
# 或者: from sklearn.grid_search import ParameterGrid [as 别名]
def fit(self, Z):
return self._fit(Z, ParameterGrid(self.param_grid))