On this page:
4.1 The #:  params bundle
4.2 Keyword conveniences
4.3 Evaluation sets
4.4 Updating a booster’s parameters
9.2

4 Setting Parameters🔗ℹ

XGBoost is configured by a set of string-keyed parameters — the objective, tree depth, learning rate, and so on. The Racket API lets you pass them in two complementary ways.

4.1 The #:params bundle🔗ℹ

#:params takes a hash or association list of parameters. Keys may be strings, symbols, or keywords; symbol and keyword keys are normalized to XGBoost’s underscore style (hyphens become underscores), and values are converted to strings before reaching the native layer:

(train dtrain
       #:params '((objective  . "reg:squarederror")
                  (max-depth  . 3)
                  (eta        . 0.1)
                  (tree-method . "hist")))

Here 'max-depth reaches XGBoost as "max_depth", and the numeric 3 becomes "3".

4.2 Keyword conveniences🔗ℹ

The most common parameters also have dedicated keywords on train: #:objective, #:eta, #:max-depth, #:num-class, #:eval-metric, and #:verbosity. They are applied after #:params, so a keyword overrides any same-named entry in the bundle:

(train dtrain
       #:objective "binary:logistic"
       #:max-depth 3
       #:eta 0.3
       #:verbosity 0
       #:rounds 30)

4.3 Evaluation sets🔗ℹ

To watch performance on held-out data during training, pass #:evals — a list of (cons name dmatrix) pairs. XGBoost reports each named metric per round, and the names you choose appear in the metric lines:

(train dtrain
       #:evals (list (cons "train" dtrain)
                     (cons "eval"  deval))
       #:objective "reg:squarederror"
       #:eval-metric "rmse"
       #:rounds 30)

Driving the evaluation loop yourself — to log metrics or stop early — is covered in Training.

4.4 Updating a booster’s parameters🔗ℹ

A parameter can also be set on an existing booster with booster-set-param!, which uses the same key/value coercion as #:params:

(booster-set-param! booster "tree_method" "hist")