【问题标题】:Python sklearn. Why I received warnings first time only?Python sklearn。为什么我只在第一次收到警告?
【发布时间】:2013-12-14 10:44:01
【问题描述】:

我只是第一次收到警告。 这正常吗?

>>> cv=LassoCV(cv=10).fit(x,y)
C:\Python27\lib\site-packages\scikit_learn-0.14.1-py2.7-win32.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')
>>> cv=LassoCV(cv=10).fit(x,y) 
>>> 

【问题讨论】:

  • 我想是的.. 这很正常。

标签: python scikit-learn lasso-regression


【解决方案1】:

这是因为 python 警告过滤器默认设置为仅在第一次捕获特定警告时发出警告。

如果您想获取所有警告,只需添加以下内容:

import warnings
warnings.simplefilter("always")

【讨论】:

    【解决方案2】:

    因为“目标没有收敛”。默认情况下,最大迭代次数为 1000,您没有设置它们。尝试将max_iter 参数设置为更高的值以避免警告。

    【讨论】:

    • 好的,谢谢,但我只是想知道为什么我只收到一次警告。
    • 也许它会收敛到其他迭代但不是一个!
    猜你喜欢
    • 2011-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多