You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Correctness issue in LassoLars for unluckily aligned values #2746
I think I've found a correctness bug in sklearn.linear_model.LassoLars. For me it appears only for systems with some exactly aligned (i.e., non-general position) values. It can be fixed by jiggling the RHS of the system with small random offsets. Here is test python code:
import numpy as np
import sklearn.linear_model as sklm
A = np.array([[0.0,0.0,0.0,-1.0,0.0], [0.0,-1.0,0.0,0.0,0.0]])
b = np.array([-2.5,-2.5])
lars = sklm.LassoLars(alpha=0.001, fit_intercept=False)
lars.fit(A,b)
w_nojiggle = lars.coef_
So after reading through the LARS paper (Efron, et al., 2003), it looks like adding jitter to the samples to avoid the many-regressors-at-a-time problem is actually an expected part of the algorithm (section 5, last paragraph, page 32). Given that, it seems like the LassoLars call in sklearn should probably add some small amount of jitter automatically. I'm not sure how to determine how much should be added, though.
We can add a parameter where the user can specify how much jitter to add to y. In the post above, the jitter is uniformly distributed, but I assume gaussian jitter would work too, in which case the user could specify its variance?
Yes, I'd figure some kind of noise parameter with a sensible default (maybe 10e-5 or something for single-precision floats) should work. I guess it doesn't matter much, but uniform noise might be preferable to gaussian since the parameter could be a bound on the magnitude of the noise.
✋ I'd be happy to work on this as my first sklearn PR. To summarize my understanding:
We need to add a noise kwarg to the LassoLars.fit() function.
Two options on the noise's distribution: uniform and bounded by the param; or Gaussian with the param being its variance. I can implement uniform to start with and make the PR, we can discuss further there.
Probably a test of some kind... I can take a look at how other .fit functions get tested.
To get set up, I'll make sure to read through the contributing docs, get my environment set up, and read Efron et al. 2003. 😅
Activity
agramfort commentedon Jan 13, 2014
hum... do you have some time to investigate the issue? stability of LARS
can be a pain...
fcole commentedon Jan 14, 2014
I can't look into it right now, but the workaround is enough for me at the moment. I'm also not that familiar with the LARS algorithm.
fcole commentedon Jan 21, 2014
So after reading through the LARS paper (Efron, et al., 2003), it looks like adding jitter to the samples to avoid the many-regressors-at-a-time problem is actually an expected part of the algorithm (section 5, last paragraph, page 32). Given that, it seems like the LassoLars call in sklearn should probably add some small amount of jitter automatically. I'm not sure how to determine how much should be added, though.
jnothman commentedon Apr 10, 2019
We can add a parameter where the user can specify how much jitter to add to y. In the post above, the jitter is uniformly distributed, but I assume gaussian jitter would work too, in which case the user could specify its variance?
fcole commentedon Apr 10, 2019
Wow, thanks for taking a look at this.
Yes, I'd figure some kind of noise parameter with a sensible default (maybe 10e-5 or something for single-precision floats) should work. I guess it doesn't matter much, but uniform noise might be preferable to gaussian since the parameter could be a bound on the magnitude of the noise.
angelaambroz commentedon Oct 10, 2019
✋ I'd be happy to work on this as my first sklearn PR. To summarize my understanding:
LassoLars.fit()function..fitfunctions get tested.To get set up, I'll make sure to read through the
contributingdocs, get my environment set up, and read Efron et al. 2003. 😅jnothman commentedon Oct 10, 2019
thomasjpfan commentedon Apr 20, 2020
Resolved in #15179
fcole commentedon Apr 20, 2020