quantlab.model.predefined.xgb.ccc_objective#
- quantlab.model.predefined.xgb.ccc_objective(predt, dtrain)[source]#
Gradient and hessian of the pooled CCC loss for
xgb.train(obj=...).With
mse = mean((p - t)^2)andD = var_p + var_t + (mu_p - mu_t)^2the loss isL = 1 - ccc = mse / D, whose derivative with respect to one prediction is2 / (n * D) * ((p_i - t_i) - L * (p_i - mu_t)). Both gradient and hessian are multiplied byn, which leaves the optimum unchanged but keeps the Newton steps from being swamped by the L2 regularisationlambda. The exact hessian is dense and its diagonal turns negative whenccc < 0, so the positive constant2 / D(the curvature of the numeratormsewithDheld fixed) is used instead.Each label column is its own pooled loss, so a multi-label DMatrix trains every output on its own CCC. A column whose
Dis not a positive finite number (for example constant predictions and labels that are equal) gets a zero gradient and a unit hessian for that round.- Parameters:
- predtnp.ndarray
The Booster’s current raw predictions for
dtrain.- dtrainxgb.DMatrix
The training
DMatrix, whose labels are read back. Rows with non-finite labels must already have been dropped.
- Returns:
- tuple[np.ndarray, np.ndarray]
(grad, hess), each shaped likepredt.
- 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])) >>> grad, hess = ccc_objective(np.array([1.0, 2.0, 3.0]), dm) >>> grad array([0., 0., 0.], dtype=float32)