# Least-Angle Regression (LARS) package

**URL:** <https://discourse.julialang.org/t/least-angle-regression-lars-package/68424>\
**Category:** Optimization (Mathematical)\
**Created:** [September 19, 2021, 8:23pm UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424 "2021-09-19T20:23:55Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![Albert\_Zevelev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albert_zevelev/32/11844_2.png) [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Post date:** [September 20, 2021, 7:47pm UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/22 "2021-09-20T19:47:10Z")

</div>

The old LARS.jl has an MIT expat license  
Should be no prob porting  
If anyone here wants to PR

---

<div class="post-metadata">

**Author:** ![Frederic\_Gilt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frederic_gilt/32/13807_2.png) [@Frederic\_Gilt](https://discourse.julialang.org/u/Frederic_Gilt)\
**Post date:** [September 21, 2021, 6:49am UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/23 "2021-09-21T06:49:39Z")

</div>

super ! I want to help w.r.t. my low level in Julia, how can I proceed ?

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [September 21, 2021, 7:18am UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/24 "2021-09-21T07:18:05Z")

</div>

> [@Frederic\_Gilt](#):
>
> can’t you mimic the old LARS package we are trying to raise from its graveyard ?

the point I was trying to make is that all models that are currently in MLJLM correspond to types or compositions of types to which there are a number of methods associated like `objective`. This is convenient because you can then throw any number of compatible optimisers at the problem. It also makes comparisons easier.

LARS to the best of my knowledge does not correspond to the minimisation of some loss, it’s just a procedure (at least as far as I can see from [https://statweb.stanford.edu/~tibs/ftp/lars.pdf](https://statweb.stanford.edu/~tibs/ftp/lars.pdf)) also note that (again, as far as I’m aware) LASSO and LARS lead to similar results and LASSO _is_ included in MLJLM (and I think it’s much faster to get the LASSO via FISTA than it is to get LARS).

Anyway as I said above, I’m not against adding LARS or RANSAC to MLJLM, maybe as a submodule or whatever. What you could do then is to take the code from LARS.jl, update it (or rewrite it) probably starting from Steven’s branch, maybe doing that in a separate repo so it’s easier to collaborate/review and once that works well then we can look into incorporating it into MLJLM.

---

<div class="post-metadata">

**Author:** ![Frederic\_Gilt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frederic_gilt/32/13807_2.png) [@Frederic\_Gilt](https://discourse.julialang.org/u/Frederic_Gilt)\
**Post date:** [September 21, 2021, 7:52am UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/25 "2021-09-21T07:52:50Z")

</div>

ok I get it. The LARS original code calls its covtest.jl own covariance function, do you think it’s better to keep it or rely on other newer code ?

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [September 21, 2021, 9:51am UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/26 "2021-09-21T09:51:07Z")

</div>

If I were to do that, I’d start from scratch first with an eye on the paper so that you’re sure of each step of the algorithm, and use basic functions for each step as opposed to optimised or specific BLAS ones (some of the stuff in the LARS.jl code are optimisations that are not relevant anymore as far as I’m aware); then once you have something working that gives comparable results to sklearn, you can get people to help you review the code and help you make it more performant.

---

<div class="post-metadata">

**Author:** ![floswald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floswald/32/195_2.png) [@floswald](https://discourse.julialang.org/u/floswald)\
**Post date:** [September 21, 2021, 2:14pm UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/27 "2021-09-21T14:14:00Z")

</div>

FWIW, the quick RCall.jl solution could be

```julia
julia> using RCall

R> library(glmnet); library(lars)
┌ Warning: RCall.jl: Loading required package: Matrix
│ Loaded glmnet 4.1-2
│ Loaded lars 1.2
│ 
└ @ RCall ~/.julia/packages/RCall/iMDW2/src/io.jl:160

R> data(QuickStartExample)

R> x <- QuickStartExample$x

R> y <- QuickStartExample$y

R> fit_lars <- lars(x, y, type = "lar", intercept = F, normalize = F)

R> fit_lars

Call:
lars(x = x, y = y, type = "lar", normalize = F, intercept = F)
R-squared: 0.917 
Sequence of LAR moves:
                                                          
Var 1 14 6 5 20 3 8 11 7 10 15 4 13 12 2 9 17 16 18 19
Step 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

```

---

<div class="post-metadata">

**Author:** ![Frederic\_Gilt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frederic_gilt/32/13807_2.png) [@Frederic\_Gilt](https://discourse.julialang.org/u/Frederic_Gilt)\
**Post date:** [September 21, 2021, 3:54pm UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/28 "2021-09-21T15:54:54Z")

</div>

thx a lot ! basically you call R inside Julia, isn’t it ?

---

<div class="post-metadata">

**Author:** ![floswald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floswald/32/195_2.png) [@floswald](https://discourse.julialang.org/u/floswald)\
**Post date:** [September 21, 2021, 4:05pm UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/29 "2021-09-21T16:05:25Z")

</div>

exactly. it may be a way to get your application running quickly - of couse if your aim is to build a pure julia package, I don’t want to discourage you from that!

---

<div class="post-metadata">

**Author:** ![Frederic\_Gilt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frederic_gilt/32/13807_2.png) [@Frederic\_Gilt](https://discourse.julialang.org/u/Frederic_Gilt)\
**Post date:** [September 21, 2021, 4:24pm UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/30 "2021-09-21T16:24:51Z")

</div>

that’s exactly how it is. I think I will use your solution now to solve my problem while taking some time to try to build something relevant for the community

---

<div class="post-metadata">

**Author:** ![Baba\_Yara\_Fahiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baba_yara_fahiz/32/36478_2.png) [@Baba\_Yara\_Fahiz](https://discourse.julialang.org/u/Baba_Yara_Fahiz)\
**Post date:** [July 12, 2022, 12:12am UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/31 "2022-07-12T00:12:42Z")

</div>

This is a working branch?  
If yes, I might fork it and keep that version up.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 12, 2022, 1:02pm UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/32 "2022-07-12T13:02:44Z")

</div>

> [@Baba\_Yara\_Fahiz](#):
>
> This is a working branch?

As I wrote in my PR, the package tests pass, so it seems to be working at some level, but I haven’t performed any other validation. [julia 1 compatibility by stevengj · Pull Request #8 · simonster/LARS.jl · GitHub](https://github.com/simonster/LARS.jl/pull/8)

---

<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:** [July 13, 2022, 11:33am UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/33 "2022-07-13T11:33:43Z")

</div>

Thanks. I took your version for a spin (comparing some of my own Convex.jl based code).

Seems to work well with Julia 1.7.3 (current packages) once `iceil(` is replaced by `ceil(Int,` in two places (lar.jl line 95 and covtest.jl line 21).

Suggestion to any future maintainer: can probably be released pretty soon, but it would be useful with an update of the documentation (in particular, how to extract/use the output).

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 13, 2022, 1:03pm UTC](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424/34 "2022-07-13T13:03:34Z")

</div>

> [@Paul\_Soderlind](#):
>
> Seems to work well with Julia 1.7.3 (current packages) once `iceil(` is replaced by `ceil(Int,` in two places (lar.jl line 95 and covtest.jl line 21).

Thanks, I updated my PR.

[Previous page](https://discourse.julialang.org/t/least-angle-regression-lars-package/68424.md?page=1)
