Utils
- deel.puncc.api.utils.alpha_calib_check(alpha, n, complement_check=False)
Check if the value of alpha \(\alpha\) is consistent with the size of calibration set \(n\).
The quantile order is inflated by a factor \((1+1/n)\) and has to be in the interval (0,1). From this, we derive the condition:
\[0 < (1-\alpha)\cdot(1+1/n) < 1 \implies 1 > \alpha > 1/(n+1)\]If complement_check is set, we consider an additional condition:
\[0 < \alpha \cdot (1+1/n) < 1 \implies 0 < \alpha < n/(n+1)\]- Parameters:
alpha (float or np.ndarray) – target quantile order.
n (int) – size of the calibration dataset.
complement_check (bool) – complementary check to compute the \(\alpha \cdot (1+1/n)\)-th quantile, required by some methods such as jk+.
- Raises:
ValueError – when \(\alpha\) is inconsistent with the size of calibration set.
- deel.puncc.api.utils.quantile(a, q, w=None, axis=None, feature_axis=None)
Estimate the columnwise q-th empirical weighted quantiles.
- Parameters:
a (Iterable) – collection of n samples
q (Union[float, np.ndarray]) – q-th quantiles to compute. All elements must be in (0, 1).
w (ndarray) – vector of size n. By default, w is None and equal weights (\(1/n\)) are associated.
axis (int) – axis along which to compute quantiles. If None, quantiles are computed along the flattened array.
feature_axis (int) – if multidim quantile, feature_axis is the axis corresponding to the features.
- Raises:
ValueError – all coordinates of q must be in (0, 1).
- Returns:
weighted empirical quantiles.
- Return type:
Union[float, np.ndarray]