Skip to content

xgboost/quantile-eval-without-train-ref

Pack Severity Fix Versions
XGBoost error none, edit by hand All versions

XGBoost train requires a separate QuantileDMatrix or ExtMemQuantileDMatrix used for evaluation to reference the exact matrix passed as dtrain. The reference makes the two matrices use the same quantile cuts.

train = xgb.QuantileDMatrix(X_train, label=y_train)
valid = xgb.QuantileDMatrix(X_valid, label=y_valid)
valid = xgb.QuantileDMatrix(X_valid, label=y_valid, ref=train)
model = xgb.train({}, train, evals=[(train, "train"), (valid, "valid")])

The rule checks literal evals lists and tuples passed to train. It checks evaluation matrices constructed inline or directly before training with ref omitted or set to None. It also reports a reference when separate constructor calls establish that ref and dtrain are different objects. The training matrix itself can appear in the evaluation list.

Pass the training matrix as ref when you construct the evaluation matrix. If you construct dtrain inside the call, assign it to a name first and reuse that name for both arguments. You can also use a regular DMatrix for evaluation.

QuantileDMatrix API · XGBoost 3.4.2 train implementation

XGBoost train requires an evaluation QuantileDMatrix or ExtMemQuantileDMatrix to reference the training matrix. Construct it with ref set to the matrix passed as dtrain.

See all rules in the XGBoost pack.