Skip to content

Inference Results

glide.mean_inference_results.base

MeanInferenceResult dataclass

Base class for mean inference results.

Source code in glide/mean_inference_results/base.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@dataclass(repr=False)
class MeanInferenceResult:
    """Base class for mean inference results."""

    confidence_interval: ConfidenceInterval
    metric_name: str
    estimator_name: str

    @property
    def width(self) -> float:
        result = self.confidence_interval.width
        return result

    @property
    def mean(self) -> float:
        return self.confidence_interval.mean

    @property
    def std(self) -> float:
        return self.confidence_interval.std

    def _common_lines(self) -> list:
        lower_bound = self.confidence_interval.lower_bound
        upper_bound = self.confidence_interval.upper_bound
        confidence_level_pct = self.confidence_interval.confidence_level * 100
        return [
            f"Metric: {self.metric_name}",
            f"Point Estimate: {self.mean:.3f}",
            f"Confidence Interval ({confidence_level_pct:.0f}%): [{lower_bound:.3f}, {upper_bound:.3f}]",
            f"Estimator : {self.estimator_name}",
        ]

    def __str__(self) -> str:
        return "\n".join(self._common_lines())

    def summary(self) -> str:
        """Return a formatted summary of the inference result."""
        return self.__str__()

    def __repr__(self) -> str:
        return self.__str__()

summary

summary()

Return a formatted summary of the inference result.

Source code in glide/mean_inference_results/base.py
41
42
43
def summary(self) -> str:
    """Return a formatted summary of the inference result."""
    return self.__str__()

glide.mean_inference_results.classical

ClassicalMeanInferenceResult dataclass

Bases: MeanInferenceResult

Mean inference result for classical (non-bootstrap) methods.

Source code in glide/mean_inference_results/classical.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
@dataclass(repr=False)
class ClassicalMeanInferenceResult(MeanInferenceResult):
    """Mean inference result for classical (non-bootstrap) methods."""

    confidence_interval: ConfidenceInterval
    metric_name: str
    estimator_name: str
    n: int = 0

    def __str__(self) -> str:
        lines = self._common_lines() + [
            f"n: {self.n}",
        ]
        return "\n".join(lines)

glide.mean_inference_results.prediction_powered

PredictionPoweredMeanInferenceResult dataclass

Bases: MeanInferenceResult

Mean inference result for prediction-powered methods.

Source code in glide/mean_inference_results/prediction_powered.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@dataclass(repr=False)
class PredictionPoweredMeanInferenceResult(MeanInferenceResult):
    """Mean inference result for prediction-powered methods."""

    confidence_interval: ConfidenceInterval
    metric_name: str
    estimator_name: str
    n_true: int = 0
    n_proxy: int = 0
    effective_sample_size: int = 0

    def __str__(self) -> str:
        lines = self._common_lines() + [
            f"n_true: {self.n_true}",
            f"n_proxy: {self.n_proxy}",
            f"Effective Sample Size: {self.effective_sample_size:}",
        ]
        return "\n".join(lines)