dmlc / XGBoost.jl

XGBoost Julia Package
Other
288 stars 111 forks source link

Watchlist error #186

Closed gyansinha closed 12 months ago

gyansinha commented 12 months ago

I get the following error when using the watchlist argument: Exception while generating log record in module XGBoost at /home/*****/.julia/packages/XGBoost/GbPms/src/booster.jl:328 │ exception = │ type Tuple has no field handle

The command works by removing the watchlist argument in the xgboost function.

MWE extract

params = Dict(
    :seed=> 1,
    :num_round => NUM_ITERATIONS,
    :booster => "gbtree",
    :objective => "binary:logistic",
    :verbosity =>  1,
    :eta => 0.01,
    :gamma =>  0,
    :max_depth =>  7,
    :min_child_weight =>  1,
    :max_delta_step =>  0,
    :subsample =>  0.9,
    :colsample_bytree =>  0.9,
    :colsample_bylevel =>  0.9,
    :colsample_bynode =>  1.0,
    :lambda =>  1,
    :alpha =>  0,
    :refresh_leaf =>  1,
    :process_type =>  "default",
    :tree_method =>  "hist",
    :num_parallel_tree =>  1,
    :grow_policy =>  "depthwise",
    :max_bin =>  256,
    :predictor => "auto"
)

dtrain    = XGBoost.DMatrix(x_train, y_train)
dtest     = XGBoost.DMatrix(x_test, y_test)
watchlist = [(dtrain, "train"), (dtest, "eval")]

bst       = xgboost(dtrain;  watchlist=watchlist, params...)

=== Julia Version 1.9.2 Commit e4ee485e909 (2023-07-05 09:39 UTC) Platform Info: OS: Linux (x86_64-linux-gnu) CPU: 8 × Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-14.0.6 (ORCJIT, broadwell) Threads: 1 on 8 virtual cores Environment: LD_LIBRARY_PATH = JULIA_EDITOR = code JULIA_NUM_THREADS =

XGBoost v2.3.1

gyansinha commented 12 months ago

This is fixed if you replace the line:

watchlist = [(dtrain, "train"), (dtest, "eval")]

with

watchlist = Dict("train" => dtrain, "eval" => dtest)

I should have read the docstring properly - sorry!