Skip to content

Commit

Permalink
Allow zero alpha if lambda is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox authored and AsafManela committed Feb 28, 2021
1 parent 338e83f commit ea74151
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Lasso"
uuid = "b4fcebef-c861-5a0f-a7e2-ba9dc32b180a"
version = "0.6.0"
version = "0.6.1"

[deps]
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Expand Down
7 changes: 4 additions & 3 deletions src/Lasso.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ const MAX_DEV_FRAC = 0.999

# Compute automatic λ values based on λmax and λminratio
function computeλ(λmax, λminratio, α, nλ)
!iszero(α) || error("α must be nonzero for λ to be computed automatically.")
λmax /= α
logλmax = log(λmax)
exp.(range(logλmax, stop=logλmax + log(λminratio), length=nλ))
Expand Down Expand Up @@ -404,8 +405,8 @@ fit(LassoPath, X, y, Binomial(), Logit();
`λmax` to `λminratio * λmax`.
- `α=1`: Value between 0 and 1 controlling the balance between ridge (``\alpha = 0``)
and lasso (``\alpha = 1``) regression.
α cannot be set to 0, though it may be set to 1.
- `nλ=100` number of λ values to use
`α` cannot be set to 0 if `λ` was not specified , though it may be set to 1.
- `nλ=100` number of `λ` values to use
- `λminratio=1e-4` if more observations than predictors otherwise 0.001.
- `stopearly=true`: When `true`, if the proportion of deviance explained
exceeds 0.999 or the difference between the deviance explained by successive λ
Expand Down Expand Up @@ -477,7 +478,7 @@ function StatsBase.fit(::Type{LassoPath},

# Lasso initialization
α = convert(T, α)
0 < α <= 1 || error("α must satisfy 0 < α <= 1")
0 <= α <= 1 || error("α must satisfy 0 <= α <= 1")
λminratio = convert(T, λminratio)
coefitr = randomize ? RandomCoefficientIterator(rng) : (1:0)

Expand Down

2 comments on commit ea74151

@AsafManela
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/30949

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.1 -m "<description of version>" ea7415134a69c085d4c9315a4b8111b172cd5c0a
git push origin v0.6.1

Please sign in to comment.