dmlc / XGBoost.jl

XGBoost Julia Package
Other
288 stars 110 forks source link

verbosity=0 and/or silent=true not working #140

Closed bobaronoff closed 1 year ago

bobaronoff commented 1 year ago

This has been discussed in prior issues (71 and 98). The XGBoost general parameter verbosity is not suppressing info output. Prior entries suggest using silent=true but this also fails to suppress info. This occurs whether or not call is inside a function. Is there a way to suppress all output?

Thank you.

Example:

X,y=rand(200,10),rand(200)
b= xgboost((X,y), num_round=3 , max_depth=6, eta=0.1 , objective="reg:squarederror" ,
                    verbosity=0, silent=true)

Output:

[ Info: XGBoost: starting training.
[ Info: [1]     train-rmse:0.28401688064633729
[ Info: [2]     train-rmse:0.27097061058948796
[ Info: [3]     train-rmse:0.26048148835406215
[ Info: Training rounds complete.
╭──── XGBoost.Booster ─────────────────────────────────────────────────────────────────╮
│  Features: 10 (unknown names)                                                        │
│                                                                                      │
│     Parameter          Value                                                         │
│   ──────────────────────────────────                                                 │
│        eta              0.1                                                          │
│                                                                                      │
│     max_depth            6                                                           │
│                                                                                      │
│     objective     reg:squarederror                                                   │
│                                                                                      │
│      silent             true                                                         │
│                                                                                      │
│     verbosity            0                                                           │
│                                                                                      │
╰──── boosted rounds: 3 ───────────────────────────────────────────────────────────────╯
ExpandingMan commented 1 year ago

There isn't a silent or verbosity argument so this is a case of us not properly validating keyword arguments.

You should set watchlist to an empty collection to silence this. I'm pretty sure this is documented but it can probably be improved.

bobaronoff commented 1 year ago

Do note that the XGBoost parameter documentation indicate that verbosity is a global and general parameter and that the Python and R implementations have functions to set this configuration ( xgboost.config_context() for Python; xib.config() for R). I do notice the Lib.jl file in the src folder has two function wrappers to set and get configuration. Can these be used to suppress output? If so, how is that done? The booster output seems specific to this implementation; can it be supressed?

function XGBSetGlobalConfig(config)
    @ccall libxgboost.XGBSetGlobalConfig(config::Ptr{Cchar})::Cint
end

function XGBGetGlobalConfig(out_config)
    @ccall libxgboost.XGBGetGlobalConfig(out_config::Ptr{Ptr{Cchar}})::Cint
end
bobaronoff commented 1 year ago

watchlist=[] suppresses output. this solves my issue. will close this thread. Thank you.