mapie.metrics.classification_mean_width_score

mapie.metrics.classification_mean_width_score(y_pred_set: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) float[source]

Mean width of prediction set output by MapieClassifier.

Parameters
y_pred_set: ArrayLike of shape (n_samples, n_class)

Prediction sets given by booleans of labels.

Returns
float

Mean width of the prediction set.

Examples

>>> from mapie.metrics import classification_mean_width_score
>>> import numpy as np
>>> y_pred_set = np.array([
...     [False, False,  True,  True],
...     [False,  True, False,  True],
...     [False,  True,  True, False],
...     [False, False,  True,  True],
...     [False,  True, False,  True]
... ])
>>> print(classification_mean_width_score(y_pred_set))
2.0