Python GridSearchCV函数给出的警告太多

Python GridSearchCV函数给出的警告太多,python,scikit-learn,warnings,Python,Scikit Learn,Warnings,我正在运行GridSearchCV函数来搜索套索回归模型的最佳alpha(正则化项系数) 当我像这样运行网格搜索时 _model = Lasso() param_dict = {'alpha': [1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1]} gsearch = GridSearchCV(_model, param_dict, cv=5, scoring='neg_mean_squared_error', n_jobs=5) 相同的ConvergenceWarnin

我正在运行
GridSearchCV
函数来搜索套索回归模型的最佳
alpha
(正则化项系数)

当我像这样运行网格搜索时

_model = Lasso()
param_dict = {'alpha': [1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1]}
gsearch = GridSearchCV(_model, param_dict, cv=5, scoring='neg_mean_squared_error', n_jobs=5)
相同的
ConvergenceWarning
会出现大约20次,如下所示

/home/user/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:491: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations. Fitting data with very small alpha may cause precision problems.
  ConvergenceWarning)
/home/user/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:491: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations. Fitting data with very small alpha may cause precision problems.
  ConvergenceWarning)
/home/user/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:491: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations. Fitting data with very small alpha may cause precision problems.
  ConvergenceWarning)
/home/user/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:491: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations. Fitting data with very small alpha may cause precision problems.
  ConvergenceWarning)
....
ConvergenceWarning
很重要,但是当它像这样显示这么多次时,就很烦人了。
是否有其他方法可以只显示一次此
聚合警告

我认为您应该使用
警告
模块来处理此问题

import warnings
warnings.warn("once")
上述代码将只打印一次警告


您可以浏览警告模块

我认为您应该使用
警告
模块来处理它

import warnings
warnings.warn("once")
上述代码将只打印一次警告


您可以浏览警告模块

我添加了您编写的代码,但没有解决问题。我添加了您编写的代码,但没有解决问题。