python - sklearn 上的套索不收敛

标签 python machine-learning least-squares scikit-learn

当我运行类似的东西时

import numpy
from sklearn import linear_model
A= #something
b= #something
clf=linear_model.Lasso(alpha=0.015, fit_intercept=False, tol=0.00000000000001,
          max_iter=10000000000000, positive=True)
clf.fit(A,b)

我得到错误:

usr/local/lib/python2.7/dist-packages/scikit_learn-0.14.1-py2.7-linux-x86_64.egg/
sklearn/linear_model/coordinate_descent.py:418: UserWarning: Objective did not
converge. You might want to increase the number of iterations
' to increase the number of iterations')

有趣的是,A 永远不会是低秩的。 (我认为)

最佳答案

尝试增加 tol。

来自documentation :

tol : float, optional

The tolerance for the optimization: if the updates are smaller than tol, the optimization code checks the dual gap for optimality and continues until it is smaller than tol.

在我的 scikit-learn 版本中,tol 的默认值是 0.0001。我假设您的容忍度很小,以至于优化永远不会达到较低的值。

关于python - sklearn 上的套索不收敛,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20681864/

相关文章:

python - 使用 Python 重写 selenium 中 webElement 的 .click() 方法

python - Sphinx : modules. 第一个:警告:文档不包含在任何 toctree 中

r - R 中随机森林回归模型中的 corr.bias 参数

matlab - 使用 MATLAB 优化工具箱进行最小二乘圆拟合

statistics - 线性回归与SPSS中的普通最小二乘一样吗?

python - 在 Github 页面上托管由 Pelican 驱动的博客

python - Windows 上的 Pyreadline 任意自动完成

machine-learning - 计算朴素贝叶斯分类中的概率

python - 是否有明确定义的 next_batch 函数?

c - C 的非线性最小二乘优化库