首页 > 解决方案 > 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 没有停止?

标签: pythonscikit-learn

解决方案


推荐阅读