autocast.metrics.coverage#

class Coverage(coverage_level=0.95, **kwargs)[source]#

Bases: BTSCMMetric

Coverage probability for a fixed coverage level.

Calculates the proportion of true values that fall within the symmetric prediction interval defined by the coverage level.

Parameters:

coverage_level (float)

name: str = 'coverage'#
class MultiCoverage(coverage_levels=None)[source]#

Bases: Metric

Computes coverage for multiple coverage levels at once.

This is a wrapper around multiple Coverage metrics. It inherits from Metric to integrate with PyTorch Lightning and TorchMetrics.

Parameters:

coverage_levels (list[float] | None)

update(y_pred, y_true)[source]#

Override this method to update the state variables of your metric class.

compute()[source]#

Compute the Average Calibration Error.

Return type:

Tensor

compute_detailed()[source]#

Return a dict of results, keys formatted as ‘coverage_{coverage_level}’.

Return type:

dict[str, float]

plot(save_path=None, title='Coverage Plot', cmap_str='viridis', save_csv=True)[source]#

Plot reliability diagram showing expected vs observed coverage.

Parameters:
  • save_path (Path | str | None) – Path to save the plot (PNG). If provided and save_csv=True, a CSV file with the same name will also be saved.

  • title (str) – Plot title.

  • cmap_str (str) – Color map string from matplotlib.

  • save_csv (bool) – If True and save_path is provided, save plot data as CSV before creating the plot.

Returns:

matplotlib.figure.Figure

reset()[source]#

Reset metric state variables to their default value.