construct_confidence_region#

mlquantify.confidence.construct_confidence_region(prev_estims, confidence_level=0.95, method='intervals')[source]#

Instantiate a confidence region from bootstrap prevalence estimates.

Factory function that selects the appropriate confidence-region class based on the chosen method and returns a fitted instance.

Parameters:
prev_estimsarray-like of shape (m, n_classes)

Collection of m bootstrap prevalence estimates.

confidence_levelfloat, default=0.95

Desired confidence level \(1 - \alpha\).

method{‘intervals’, ‘ellipse’, ‘ellipse-clr’, ‘clr’}, default=’intervals’

Confidence region type.

Returns:
regionBaseConfidenceRegion

Fitted confidence region object.

Raises:
NotImplementedError

If method is not one of the recognised identifiers.

Examples

>>> import numpy as np
>>> from mlquantify.confidence import construct_confidence_region
>>> samples = np.random.dirichlet([2, 2, 2], size=200)
>>> cr = construct_confidence_region(samples, confidence_level=0.9,
...                                  method="ellipse")
>>> cr.get_point_estimate().shape
(3,)