Skip to content

Commit ea74151

Browse files
oxinaboxAsafManela
authored andcommitted
Allow zero alpha if lambda is specified
1 parent 338e83f commit ea74151

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Lasso"
22
uuid = "b4fcebef-c861-5a0f-a7e2-ba9dc32b180a"
3-
version = "0.6.0"
3+
version = "0.6.1"
44

55
[deps]
66
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"

src/Lasso.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ const MAX_DEV_FRAC = 0.999
208208

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

478479
# Lasso initialization
479480
α = convert(T, α)
480-
0 < α <= 1 || error("α must satisfy 0 < α <= 1")
481+
0 <= α <= 1 || error("α must satisfy 0 <= α <= 1")
481482
λminratio = convert(T, λminratio)
482483
coefitr = randomize ? RandomCoefficientIterator(rng) : (1:0)
483484

0 commit comments

Comments
 (0)