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

Bug: BoundsError: attempt to access 200-element Array{Float64,1} at index [201] #54

Open
Gobutah opened this issue Sep 30, 2020 · 2 comments

Comments

@Gobutah
Copy link

Gobutah commented Sep 30, 2020

The following code leads to an error:


               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.5.1 (2020-08-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.5) pkg> status Lasso
Status `~/.julia/environments/v1.5/Project.toml`
  [b4fcebef] Lasso v0.5.2

julia> using Lasso

julia> lambdas=[0.001];

julia> X=rand(100,13500);

julia> Y=rand(100);

julia> res=fit(LassoPath, X, Y;λ=lambdas)
ERROR: BoundsError: attempt to access 200-element Array{Float64,1} at index [201]
Stacktrace:
 [1] getindex at ./array.jl:809 [inlined]
 [2] update_coef! at /home/peter/.julia/packages/Lasso/HtY0O/src/coordinate_descent.jl:189 [inlined]
 [3] cycle!(::Lasso.SparseCoefficients{Float64}, ::NaiveCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}, ::Float64, ::Bool) at /home/peter/.julia/packages/Lasso/HtY0O/src/coordinate_descent.jl:246
 [4] cdfit!(::Lasso.SparseCoefficients{Float64}, ::NaiveCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}, ::Float64, ::Symbol) at /home/peter/.julia/packages/Lasso/HtY0O/src/coordinate_descent.jl:598
 [5] fit!(::LassoPath{LinearModel{GLM.LmResp{Array{Float64,1}},NaiveCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}; verbose::Bool, cd_maxiter::Int64, cd_tol::Float64, irls_tol::Float64, stopearly::Bool, criterion::Symbol, minStepFac::Float64) at /home/peter/.julia/packages/Lasso/HtY0O/src/coordinate_descent.jl:827
 [6] fit(::Type{LassoPath}, ::Array{Float64,2}, ::Array{Float64,1}, ::Normal{Float64}, ::IdentityLink; wts::Array{Float64,1}, offset::Array{Float64,1}, α::Float64, nλ::Int64, λminratio::Float64, λ::Array{Float64,1}, standardize::Bool, intercept::Bool, algorithm::Type{T} where T, dofit::Bool, irls_tol::Float64, randomize::Bool, maxncoef::Int64, penalty_factor::Nothing, standardizeω::Bool, fitargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}) at /home/peter/.julia/packages/Lasso/HtY0O/src/Lasso.jl:491
 [7] top-level scope at REPL[6]:1

@mapi1
Copy link

mapi1 commented Oct 19, 2020

Ran into the same Error, seems to derail for a certain observation regressor ratio lower than 0.5 for me.

@jolars
Copy link
Contributor

jolars commented May 12, 2022

For me, setting maxncoef to something large solves this issue. I'm guessing that the package hard-codes an array for storage of coefficients that's of dimension maxncoef but then for low regularization may end up picking more than maxncoef features to be nonzero (which I'm not sure should actually happen given the earlystopping criteria).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants