JuliaStats / Lasso.jl

Lasso/Elastic Net linear and generalized linear models
Other
143 stars 31 forks source link

`linspace` error with bad inputs #14

Closed iamed2 closed 6 years ago

iamed2 commented 6 years ago
julia> fit(LassoPath, hcat(ones(1000), rand(1000, 7)), rand(1000))
ERROR: ArgumentError: start and stop must be finite, got NaN and NaN
Stacktrace:
 [1] _linspace(::Float64, ::Float64, ::Int64) at ./twiceprecision.jl:342
 [2] linspace(::Float64, ::Float64, ::Int64) at ./twiceprecision.jl:338
 [3] computeλ(::Array{Float64,1}, ::Float64, ::Float64, ::Int64, ::Void) at /Users/ericdavies/.julia/v0.6/Lasso/src/Lasso.jl:213
 [4] build_model(::Array{Float64,2}, ::Array{Float64,1}, ::Distributions.Normal{Float64}, ::GLM.IdentityLink, ::Lasso.CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Void}, ::Float64, ::Void, ::Array{Float64,1}, ::Array{Float64,1}, ::Float64, ::Int64, ::Void, ::Bool, ::Float64) at /Users/ericdavies/.julia/v0.6/Lasso/src/Lasso.jl:242
 [5] #fit#1(::Array{Float64,1}, ::Array{Float64,1}, ::Float64, ::Int64, ::Float64, ::Void, ::Bool, ::Bool, ::Type{T} where T, ::Bool, ::Float64, ::Bool, ::Int64, ::Void, ::Array{Any,1}, ::StatsBase.#fit, ::Type{Lasso.LassoPath}, ::Array{Float64,2}, ::Array{Float64,1}, ::Distributions.Normal{Float64}, ::GLM.IdentityLink) at /Users/ericdavies/.julia/v0.6/Lasso/src/Lasso.jl:328
 [6] fit(::Type{Lasso.LassoPath}, ::Array{Float64,2}, ::Array{Float64,1}, ::Distributions.Normal{Float64}, ::GLM.IdentityLink) at /Users/ericdavies/.julia/v0.6/Lasso/src/Lasso.jl:297 (repeats 2 times)

I'm not exactly sure what causes this but it seems like this error shouldn't occur. I would expect just a failure to converge?

simonster commented 6 years ago

If you put an intercept in the design matrix and don't set intercept=false, the full model is rank-deficient. In general you probably don't want an L1 penalty on the intercept. See #11