2013-12-19 91 views
4

當我運行像套索上sklearn不收斂

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') 

有趣的是,從來都不是排名defficient。 (我認爲)

回答

8

嘗試增加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.

爲TOL的默認值爲0.0001對我的版本的scikit學習。我認爲你的容忍度非常小,優化永遠不會達到較低的值。

+0

就是這樣!謝謝 – gota