quantlab.model.predefined.xgb.ccc_loss_metric#

quantlab.model.predefined.xgb.ccc_loss_metric(predt, dtrain)[source]#

Score a Booster’s predictions for xgb.train(custom_metric=...).

The score is pooled_ccc_loss of the predictions against the labels. Only the primary label (column 0) is scored. With multiple labels dtrain.get_label() returns a (n_rows, n_labels) array and the prediction has the same layout; both are reshaped to (n_rows, -1) before column 0 is taken, which is a no-op for a single label.

Parameters:
predtnp.ndarray

The Booster’s predictions for dtrain.

dtrainxgb.DMatrix

The evaluated DMatrix, whose labels are read back.

Returns:
tuple[str, float]

("ccc_loss", value) as xgboost expects from a custom metric.

Raises:
ValueError

If the label and prediction element counts differ.

Examples

>>> dm = xgb.DMatrix(np.zeros((3, 2)), label=np.array([1.0, 2.0, 3.0]))
>>> ccc_loss_metric(np.array([1.1, 1.9, 3.2]), dm)
('ccc_loss', 0.014084507042253502)