利用sklearn在训练模型时进行参数调优的方法

(一)GridSearchCV

网格搜索交叉验证,遍历所有可能参数的组合。CV表示cross validation。

sklearn.model_selection.GridSearchCV(estimator, param_grid, scoring=None, fit_params=None, n_jobs=1, iid=True, refit=True, cv=None, verbose=0, pre_dispatch=‘2*n_jobs’, error_score=’raise’, return_train_score=’warn’)

参数列表详见:http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html

(二)RandomizedSearchCV

随即搜索交叉验证,在参数空间中以随机采样的方式进行参数的组合。

sklearn.grid_search.RandomizedSearchCV(estimator, param_distributions, n_iter=10, scoring=None, fit_params=None, n_jobs=1, iid=True, refit=True, cv=None, verbose=0, pre_dispatch=‘2*n_jobs’, random_state=None, error_score=’raise’)

参数列表详见:http://scikit-learn.org/stable/modules/generated/sklearn.grid_search.RandomizedSearchCV.html

参考:https://www.cnblogs.com/nolonely/p/7007961.html

猜你喜欢

转载自blog.csdn.net/weixin_40941966/article/details/81170397