XGBoost.jl icon indicating copy to clipboard operation
XGBoost.jl copied to clipboard

Old syntax xgboost() results in stack overflow

Open alyst opened this issue 1 year ago • 1 comments

On XGBoost.jl v2.0.0 the command xgmodel = xgboost(train_dmtx, 5000, gamma = 1) gives

[ Info: XGBoost: starting training.                                                                                                                                                                                             
ERROR: StackOverflowError:                                                                                                                                                                                                      
Stacktrace:                                                                                                                                                                                                                     
 [1] updateone!(b::Booster, data::DMatrix, a::Int64; kw::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:round_number, :watchlist), Tuple{Int64, Dict{String, DMatrix}}}}) (repeats 32465 times)                    
   @ XGBoost ~/.julia/packages/XGBoost/wlUNO/src/booster.jl:373                                                                                                                                                                 
 [2] #update!#59                                                                                                                                                                                                                
   @ ~/.julia/packages/XGBoost/wlUNO/src/booster.jl:390 [inlined]                                                                                                                                                               
 [3] xgboost(dm::DMatrix, a::Int64; num_round::Int64, watchlist::Dict{String, DMatrix}, kw::Base.Pairs{Symbol, Int64, Tuple{Symbol, Symbol}, NamedTuple{(:gamma, :silent), Tuple{Int64, Int64}}})                               
   @ XGBoost ~/.julia/packages/XGBoost/wlUNO/src/booster.jl:430                                                                                                                                                                 
 [4] top-level scope                                                                                                                                                                                                            
   @ REPL[7]:1                                                                                                                                                                                                                  

The method in question is

updateone!(b::Booster, data, a...; kw...) = updateone!(b, DMatrix(data), a...; kw...)

It is supposed to call the more specific updateone!(b::Booster, data::DMatrix, ...), but it also requires that the a... args match the signature of the more specific method, otherwise it will recurse.

alyst avatar Nov 05 '22 08:11 alyst

I'm sure I thought having the generic method was terribly clever when I first wrote it but I agree this is too much of a footgun. I'll have to go through it a little carefully to make sure we have the right methods.

If anybody else wants to fix, I will accept the PR.

ExpandingMan avatar Nov 10 '22 00:11 ExpandingMan