Bayes Error Rate
How-To Guides
Check out this how to to begin using the ber metric.
DataEval API
- dataeval.metrics.ber(images: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], labels: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], k: int = 1, method: Literal['KNN', 'MST'] = 'KNN') BEROutput
An estimator for Multi-class Bayes Error Rate using FR or KNN test statistic basis
- Parameters:
images (ArrayLike (N, ... )) – Array of images or image embeddings
labels (ArrayLike (N, 1)) – Array of labels for each image or image embedding
k (int, default 1) – Number of nearest neighbors for KNN estimator – ignored by MST estimator
method (Literal["KNN", "MST"], default "KNN") – Method to use when estimating the Bayes error rate
- Returns:
The upper and lower bounds of the Bayes Error Rate
- Return type:
BEROutput
References
[1] Learning to Bound the Multi-class Bayes Error (Th. 3 and Th. 4)
Examples
>>> import sklearn.datasets as dsets >>> from dataeval.metrics import ber
>>> images, labels = dsets.make_blobs(n_samples=50, centers=2, n_features=2, random_state=0)
>>> ber(images, labels) BEROutput(ber=0.04, ber_lower=0.020416847668728033)