mapie.metrics.regression.hsic

mapie.metrics.regression.hsic(y_true: ndarray[tuple[Any, ...], dtype[_ScalarT]], y_intervals: ndarray[tuple[Any, ...], dtype[_ScalarT]], kernel_sizes: ArrayLike = (1, 1)) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]

Compute the square root of the hsic coefficient. HSIC is Hilbert-Schmidt independence criterion that is a correlation measure. Here we use it as proposed in [4], to compute the correlation between the indicator of coverage and the interval size.

If hsic is 0, the two variables (the indicator of coverage and the interval size) are independant.

Warning: This metric should be used only with non constant intervals (intervals of different sizes), with constant intervals the result may be misinterpreted.

[4] Feldman, S., Bates, S., & Romano, Y. (2021). Improving conditional coverage via orthogonal quantile regression. Advances in Neural Information Processing Systems, 34, 2060-2071.

Parameters:
y_true: NDArray of shape (n_samples,)

True labels.

y_intervals: NDArray of shape (n_samples, 2, n_confidence_level) or (n_samples, 2)

Prediction sets given by booleans of labels.

kernel_sizes: ArrayLike of size (2,)

The variance (sigma) for each variable (the indicator of coverage and the interval size), this coefficient controls the width of the curve.

Returns:
NDArray of shape (n_confidence_level,)

One hsic correlation coefficient by confidence level.

Raises:
ValueError

If kernel_sizes has a length different from 2 and if it has negative or null values.

Examples

>>> from mapie.metrics.regression import hsic
>>> import numpy as np
>>> y_true = np.array([9.5, 10.5, 12.5])
>>> y_intervals = np.array([
... [[9, 9], [10.0, 10.0]],
... [[8.5, 9], [12.5, 12]],
... [[10.5, 10.5], [12.0, 12]]
... ])
>>> print(hsic(y_true, y_intervals))
[0.31787614 0.2962914 ]

Examples using mapie.metrics.regression.hsic

Focus on local (or “conditional”) coverage

Focus on local (or "conditional") coverage