OCDocker.OCScore.Analysis.Metrics.Bootstrap module

Bootstrap utilities for metric confidence intervals.

Usage:

from OCDocker.OCScore.Analysis.Metrics import Bootstrap as Boot

OCDocker.OCScore.Analysis.Metrics.Bootstrap.bootstrap_ci(y_true, y_score, metric_fn, n_boot=1000, alpha=0.05, random_state=None, strata=None)[source]

Compute metric and (1-alpha) bootstrap CI. If strata is provided, resample within each stratum to preserve distribution.

Parameters:
  • y_true (array-like of shape (n_samples,)) – True binary labels (0/1 or boolean).

  • y_score (array-like of shape (n_samples,)) – Target scores, can either be probability estimates of the positive class, confidence values, or non-thresholded measure of decisions (as returned by a classifier).

  • metric_fn (callable) – Function with signature metric_fn(y_true, y_score) that returns a float.

  • n_boot (int, optional) – Number of bootstrap samples. Default is 1000. If <= 0, no boot is performed and (metric, NaN, NaN) is returned.

  • alpha (float, optional) – Significance level for the (1-alpha) confidence interval. Default is 0.05 for a 95% CI.

  • random_state (int or None, optional) – Random seed for reproducibility. Default is None.

  • strata (array-like of shape (n_samples,) or None, optional) – If provided, resample within each stratum to preserve distribution. Default is None (no stratification).

Returns:

Returns (metric, low, high).

Return type:

tuple[float, float, float]