quantlab.model.evaluation.cross_sectional_ic_series#

quantlab.model.evaluation.cross_sectional_ic_series(pred, target)[source]#

Return the per-row Pearson correlation of a panel, NaN on a skipped row.

A row (timestamp) is skipped when it has fewer than two usable symbols or when either the prediction or the target is constant over its usable symbols. Constancy is tested exactly (masked max equals masked min) rather than with a variance threshold, so genuinely small cross-sectional spreads are not misread as constant.

Parameters:
predarray_like

A 2-D [T, S] panel of predictions.

targetarray_like

A 2-D [T, S] panel of realised values.

Returns:
np.ndarray

A float64 array of length T.

Raises:
ValueError

If the inputs are not 2-D or differ in shape.

Examples

>>> pred = np.array([[1.0, 2.0, 3.0], [1.0, np.nan, 3.0], [1.0, 2.0, 3.0]])
>>> target = np.array([[1.0, 2.0, 3.0], [2.0, 5.0, 4.0], [1.0, 3.0, 2.0]])
>>> cross_sectional_ic_series(pred, target)
array([1. , 1. , 0.5])