必须有一些特定的数据. LassoLarsCV()似乎正在使用这个相当良好的数据的合成示例:
import numpy
import sklearn.linear_model
# create 40000 x 40 sample data from linear model with a bit of noise
npoints = 40000
ndims = 40
numpy.random.seed(1)
X = numpy.random.random((npoints, ndims))
w = numpy.random.random(ndims)
y = X.dot(w) + numpy.random.random(npoints) * 0.1
clf = sklearn.linear_model.LassoLarsCV(fit_intercept=False, normalize=False, max_n_alphas=1e6)
clf.fit(X, y)
# coefficients are almost exactly recovered, this prints 0.00377
print max(abs( clf.coef_ - w ))
# alphas actually used are 41 or ndims+1
print clf.alphas_.shape
这是在sklearn 0.16,我没有positive = True选项.
我不知道你为什么要使用非常大的max_n_alphas.虽然我不知道为什么1e 4工作而1e 5不在你的情况下,我怀疑你从max_n_alphas = ndims 1和max_n_alphas = 1e 4获得的路径或者对