quantlab.model.predefined.xgb.pooled_ccc_loss#
- quantlab.model.predefined.xgb.pooled_ccc_loss(y_true, y_pred)[source]#
Return
1 - ccc, the pooled concordance correlation loss.ccc = 2 * cov / (var_pred + var_true + (mu_pred - mu_true)^2)with population moments (ddof=0). Both inputs are flattened and scored as one pool, without any per-timestamp grouping, so the loss also rewards predicting the market-wide move of each day and penalises a correctly shrunk prediction whose variance is below the label’s.A CCC of 1 means perfect agreement, 0 no agreement and -1 perfect inverse agreement, so the loss ranges from 0 (best) to 2 (worst).
Only positions where both inputs are finite are used. When no such position remains, or the denominator is exactly zero, the loss
1.0(no agreement) is returned rather than NaN, so that early stopping can still compare rounds.- Parameters:
- y_truearray_like
Observed values, any shape.
- y_predarray_like
Predicted values, the same number of elements as
y_true.
- Returns:
- float
1 - ccc.
- Raises:
- ValueError
If the two inputs have different lengths after flattening.
Examples
>>> pooled_ccc_loss([1.0, 2.0, 3.0], [1.0, 2.0, 3.0]) 0.0 >>> pooled_ccc_loss([1.0, 2.0, 3.0], [1.1, 1.9, 3.2]) 0.014084507042253502 >>> pooled_ccc_loss([1, 2, 3], [3, 2, 1]) 2.0