-
sklearn.model_selection.GridSearchCV
class sklearn.model_selection.GridSearchCV(estimator, param_grid, scoring=None, n_jobs=None, iid=’warn’, refit=True, cv=’warn’, verbose=0, pre_dispatch=‘2*n_jobs’, error_score=’raise-deprecating’, return_train_score=False)
对评估器的指定参数进行详细搜索。
重要参数拟合并预测。
GridSearchCV执行一个’fit’和一个’score’方法,也执行’预测predict’,‘predict_proba’,‘decision_function’, “transform”, “inverse_transform” ,如果他们在所用的estimator中使用的话。
运用这些方法的estimator的参数通过一个参数网格今昔你个网格搜索交叉验证。
更多内容见:
-
Parameters
Parameters 数据类型 意义 estimator estimator object estimator都需要提供score函数 param_grid dict or list of dictionaries 参数名作为keys scoring string, callable, list/tuple, dict or None, default: None 评估预测结果。为了评估多个指标,给出一个list或dict n_jobs int or None, optional (default=None) 并行数目,None是1个。
-1是运行所有处理器pre_dispatch int, or string, optional 并行计算中控制分发的工作数目 iid boolean, default=’warn’ True:返回交叉平均得分 cv int, cross-validation generator or an iterable, optional 确定交叉验证分配策略 refit boolean, string, or callable, default=True 在全部数据集上用找到的最佳参数组合重新拟合评估器 verbose integer 控制冗长信息,数值越高信息越多 error_score ‘raise’ or numeric return_train_score boolean, default=False -
Attributes
Attributes 数据类型 意义 cv_results_ dict of numpy (masked) ndarrays 字典的keys作为column头,values作为columns best_estimator_ estimator or dict 搜索到的验证集上得分最好的Estimator best_score_ float best_estimator的平均交叉验证得分 -
Methods
Methods 意义 decision_function
(self, X)Call decision_function on the estimator with the best found parameters. fit
(self, X[, y, groups])Run fit with all sets of parameters. get_params
(self[, deep])Get parameters for this estimator. inverse_transform
(self, Xt)Call inverse_transform on the estimator with the best found params. predict
(self, X)Call predict on the estimator with the best found parameters. predict_log_proba
(self, X)Call predict_log_proba on the estimator with the best found parameters. predict_proba
(self, X)Call predict_proba on the estimator with the best found parameters. score
(self, X[, y])Returns the score on the given data, if the estimator has been refit. set_params
(self, **params)Set the parameters of this estimator. transform
(self, X)Call transform on the estimator with the best found parameters.
这篇文章翻译的更好:《使用GridSearchCV进行网格搜索》