# Lasso/lars

**URL:** https://discourse.julialang.org/t/lasso-lars/12937
**Category:** Machine Learning
**Created:** [August 6, 2018, 12:22pm UTC](https://discourse.julialang.org/t/lasso-lars/12937 "2018-08-06T12:22:31Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)
#### Post date: [August 6, 2018, 12:22pm UTC](https://discourse.julialang.org/t/lasso-lars/12937/1 "2018-08-06T12:22:31Z")

</div>

Is there a package with a LASSO/LARS algorithm? (I earlier used Lasso.jl, but it downgrades a bunch packages, so I am looking for something else.)

---

<div class="post-metadata">

### Author: ![Alan\_Crawford](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alan_crawford/32/4213_2.png) [@Alan\_Crawford](https://discourse.julialang.org/u/Alan_Crawford)
#### Post date: [August 6, 2018, 1:24pm UTC](https://discourse.julialang.org/t/lasso-lars/12937/2 "2018-08-06T13:24:07Z")

</div>

Maybe try [glmnet.jl](https://github.com/JuliaStats/GLMNet.jl)

---

<div class="post-metadata">

### Author: ![ianfiske](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@ianfiske](https://discourse.julialang.org/u/ianfiske)
#### Post date: [August 6, 2018, 1:24pm UTC](https://discourse.julialang.org/t/lasso-lars/12937/3 "2018-08-06T13:24:09Z")

</div>

Try [GitHub - JuliaStats/GLMNet.jl: Julia wrapper for fitting Lasso/ElasticNet GLM models using glmnet](https://github.com/JuliaStats/GLMNet.jl). Looks to be more recently updated.

This is a generalization of LARS/LASSO that makes a trade-off between L2 and L1 penalties. Set the alpha parameter to 1 to have a fully LASSO solution (see [https://web.stanford.edu/~hastie/glmnet/glmnet\_alpha.html](https://web.stanford.edu/~hastie/glmnet/glmnet_alpha.html) for some more details on the parameters).

---

<div class="post-metadata">

### Author: ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)
#### Post date: [August 6, 2018, 1:59pm UTC](https://discourse.julialang.org/t/lasso-lars/12937/4 "2018-08-06T13:59:20Z")

</div>

Notice that there is an open PR to fix Lasso.jl so it will probably work again soon.

---

<div class="post-metadata">

### Author: ![AsafManela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asafmanela/32/4863_2.png) [@AsafManela](https://discourse.julialang.org/u/AsafManela)
#### Post date: [August 6, 2018, 5:03pm UTC](https://discourse.julialang.org/t/lasso-lars/12937/5 "2018-08-06T17:03:28Z")

</div>

You can try my fork of Lasso.jl, which should work with v0.6.x until the PR is pulled.  
[https://github.com/AsafManela/Lasso.jl.git](https://github.com/AsafManela/Lasso.jl.git)

---

<div class="post-metadata">

### Author: ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)
#### Post date: [August 6, 2018, 8:29pm UTC](https://discourse.julialang.org/t/lasso-lars/12937/6 "2018-08-06T20:29:48Z")

</div>

If you’re into just solving the problem:

$$ \arg \min\_{x} \frac{1}{2} {\left| A x - b \right|}_{2}^{2} + \lambda {\left| x \right|}_{1} $$

Then it would take only few lines to get it done in Julia (It will be a modern and fast solution).

P. S.  
Is there a way to enable the MathJaX Plug In for this site?

---

<div class="post-metadata">

### Author: ![TsurHerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsurherman/32/1234_2.png) [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)
#### Post date: [August 6, 2018, 8:36pm UTC](https://discourse.julialang.org/t/lasso-lars/12937/7 "2018-08-06T20:36:28Z")

</div>

Share your solution

---

<div class="post-metadata">

### Author: ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)
#### Post date: [August 6, 2018, 9:03pm UTC](https://discourse.julialang.org/t/lasso-lars/12937/8 "2018-08-06T21:03:56Z")

</div>

I created a [project on GitHub called - L1 Regularized Least Squares](https://github.com/RoyiAvital/Projects/tree/master/Optimization/LsL1SolversAnalysis) (Nothing fancy, some known modern method to deal with this problem, As expected, Iteration Wise the Coordinate Descent method was the fastest).  
The implementation is in MATLAB but it will be easy to adapt it to Julia.

Once Julia 1.x.xxx is out I intent to put few of thosw into the MATLAB vs. Julia test.

---

<div class="post-metadata">

### Author: ![TsurHerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsurherman/32/1234_2.png) [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)
#### Post date: [August 7, 2018, 8:10am UTC](https://discourse.julialang.org/t/lasso-lars/12937/9 "2018-08-07T08:10:27Z")

</div>

intersting … why does your objective function starts at zero and goes down to around -100 ?

shouldn’t it go down to zero?

---

<div class="post-metadata">

### Author: ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)
#### Post date: [August 7, 2018, 8:28am UTC](https://discourse.julialang.org/t/lasso-lars/12937/10 "2018-08-07T08:28:24Z")

</div>

My mistake, I didn’t put the `[dB]` there.

**Update**  
Fixed the Y Axis Title.

---

<div class="post-metadata">

### Author: ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)
#### Post date: [August 7, 2018, 8:32am UTC](https://discourse.julialang.org/t/lasso-lars/12937/11 "2018-08-07T08:32:16Z")

</div>

Hi,  
and thanks. Works very well. May I ask if you plan to eventually update to 0.7 syntax?

By the way, glmnet.jl also worked well, but the msys2/gfortran was a 3GB installation (Win64).

---

<div class="post-metadata">

### Author: ![AsafManela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asafmanela/32/4863_2.png) [@AsafManela](https://discourse.julialang.org/u/AsafManela)
#### Post date: [August 7, 2018, 12:33pm UTC](https://discourse.julialang.org/t/lasso-lars/12937/12 "2018-08-07T12:33:12Z")

</div>

Yes. Can’t wait for that one. But GLM.jl would need to be updated first.

---

<div class="post-metadata">

### Author: ![AsafManela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asafmanela/32/4863_2.png) [@AsafManela](https://discourse.julialang.org/u/AsafManela)
#### Post date: [September 17, 2018, 2:56am UTC](https://discourse.julialang.org/t/lasso-lars/12937/13 "2018-09-17T02:56:32Z")

</div>

The following PR passes all tests with julia 0.7 and 1.0 on my linux box:  
[https://github.com/simonster/Lasso.jl/pull/19](https://github.com/simonster/Lasso.jl/pull/19)  
Note that tests on julia 1.0 require GLMNet.jl’s upgraded syntax as well, which is available now by running  
(v1.0) pkg\> add GLMNet#627355f45079e305a19541fe787bf0a00ef544f7  
Hopefully that pending pull request is merged soon.
