python - GridSearchCV 套索警告 ConvergenceWarning:目标未收敛
问题描述
我正在尝试使用 CVGridSearch 为我的数据找到最佳参数
lasso = Lasso(random_state=0)
alphas = [0.5, 0.1 , 0.01 ]
max_iter = [1000, 2000, 3000]
tuned_parameters = [{'alpha': alphas , 'max_iter' : max_iter}]
n_folds = 5
clf = GridSearchCV(lasso, tuned_parameters, cv=n_folds, refit=False)
clf.fit(X_train, y_train.values.ravel())
当我运行代码时,它会显示以下警告
Best: 0.999998 using {'alpha': 0.1, 'max_iter': 1000}
Best: -2028.743734 using {'alpha': 0.1, 'max_iter': 1000}
/usr/local/lib/python3.6/site-
packages/sklearn/linear_model/coordinate_descent.py:492:
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)
Best: -2241.410408 using {'alpha': 0.01, 'max_iter': 1000}
/usr/local/lib/python3.6/site-
packages/sklearn/linear_model/coordinate_descent.py:492:
ConvergenceWarning: Objective did not converge. You might want to
increase the number of iterations. Fitting data with very small alpha
may cause precision problems.
当找到最好的分数 0.999998 时,为什么 CVGridsearch 没有停止?
解决方案
推荐阅读
- windows - 在 Windows 应用程序 ubuntu 中使用 xdg-open
- google-chrome - localhost:3000/home.html 在 chrome 中打开谷歌搜索
- python - 如何将散景图的 html 输出转换为 pdf
- scala - 使用 scala 和 maria db 的简单 curd rest api
- python - 如何在进程终止后等待,直到使用 Python 在 Windows 上解锁文件?
- dart - 如何创建一个有 2 列的表以在颤动中显示数据?一列具有静态数据,另一列具有可编辑的空字段
- c++ - 使用 C++ 将 IP 地址附加到 char*
- c# - System.EntryPointNotFoundException 即使在 c# 代码中指定入口点(函数名)之后
- android - Android 合并 2 个数据列表,一个来自 Room LiveData,另一个来自 Observable
- jquery - $.fn.DataTable.render.text 不是函数