Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecations #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ function lars(X::Matrix{T}, y::Vector{T}; method::Symbol=:lasso,
# The system is becoming too ill-conditioned.
# We have degenerate vectors in our active set.
# We'll 'drop for good' the last regressor added
warn(@sprintf "Regressors in active set degenerate. Dropping a regressor, after %i iterations, i.e. λ=%.3e, with an active set of %i regressors, and the smallest cholesky pivot element being %.3e" niter lambda nactive diag)
@warn(@sprintf "Regressors in active set degenerate. Dropping a regressor, after %i iterations, i.e. λ=%.3e, with an active set of %i regressors, and the smallest cholesky pivot element being %.3e" niter lambda nactive diag)
# XXX: need to figure a 'drop for good' way
unshift!(Cov, removed_Cov)
pushfirst!(Cov, removed_Cov)
Cov[1] = Cov[C_idx]
Cov[C_idx] = 0
continue
Expand All @@ -312,7 +312,7 @@ function lars(X::Matrix{T}, y::Vector{T}; method::Symbol=:lasso,
# bringing in too much numerical error that is greater than
# than the remaining correlation with the
# regressors. Time to bail out
warn(@sprintf "Early stopping the lars path, as the residues are small and the current value of lambda is no longer well controlled. %i iterations, λ=%.3e, previous λ=%.3e, with an active set of %i regressors." niter lambda prev_lambda nactive)
@warn(@sprintf "Early stopping the lars path, as the residues are small and the current value of lambda is no longer well controlled. %i iterations, λ=%.3e, previous λ=%.3e, with an active set of %i regressors." niter lambda prev_lambda nactive)
break
end

Expand Down
13 changes: 13 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LARS, Test, DelimitedFiles, Statistics, LinearAlgebra
using StableRNGs

# Diabetes data set from Efron, Hastie, Johnstone, and Tibshirani (2004)
diabeetus = readdlm(joinpath(dirname(@__FILE__), "diabeetus.csv"), ',', header=true)[1]
Expand Down Expand Up @@ -102,3 +103,15 @@ coefs = [
c = lars(X, y, method=:lar, standardize=false, intercept=false)
@test c.lambdas ≈ lambdas
@test c.coefs ≈ coefs

@testset "degenerate regressors produces warning" begin

rng = StableRNG(123)
n = 100
p = 5
X = randn(rng, n, p)
X[:, 2] = X[:, 1] + 1e-10*randn(n)
y = X[:, 1] + randn(n)
@test_logs (:warn, r"^Regressors in active set degenerate.") lars(X, y, method=:lars)

end