BaseConfidenceRegion#
- class mlquantify.confidence.BaseConfidenceRegion(prev_estims, confidence_level=0.95)[source]#
Base class for confidence regions of prevalence estimates.
This class defines the interface and core structure for constructing confidence regions around class prevalence estimates obtained from quantification models.
Confidence regions capture the uncertainty associated with prevalence estimates, typically derived from bootstrap resampling as proposed in [1].
- Parameters:
- prev_estimsarray-like of shape (m, n)
Collection of
mbootstrap prevalence estimates fornclasses.- confidence_levelfloat, default=0.95
Desired confidence level \(1 - \alpha\) of the region.
- Attributes:
- prev_estimsndarray of shape (m, n)
Bootstrap prevalence estimates.
- confidence_levelfloat
Confidence level associated with the region.
Notes
The confidence region \(CR_{\alpha}\) is defined such that
\[\mathbb{P}\left(\pi^{\ast} \in CR_{\alpha}\right) = 1 - \alpha\]where \(\pi^{\ast}\) is the unknown true class-prevalence vector.
References
[1]Moreo, A., & Salvati, N. (2025). An Efficient Method for Deriving Confidence Intervals in Aggregative Quantification. Istituto di Scienza e Tecnologie dell’Informazione, CNR, Pisa.
Examples
>>> import numpy as np >>> class DummyRegion(BaseConfidenceRegion): ... def _compute_region(self): ... self.mean_ = np.mean(self.prev_estims, axis=0) ... def get_region(self): ... return self.mean_ ... def get_point_estimate(self): ... return self.mean_ ... def contains(self, point): ... return np.allclose(point, self.mean_, atol=0.1) >>> X = np.random.dirichlet(np.ones(3), size=100) >>> region = DummyRegion(X, confidence_level=0.9) >>> region.get_point_estimate().round(3) array([0.33, 0.33, 0.34])