forecaster.metrics.calculate_coverage(y_true, lower_bound, upper_bound)
Calculate coverage of a given interval.
Coverage is the proportion of true values that fall within the interval.
Returns
|
float |
Coverage of the interval. |
Examples
import numpy as np
from spotforecast2_safe.forecaster.metrics import calculate_coverage
y_true = np.array([1, 2, 3, 4, 5])
lower_bound = np.array([0.5, 1.5, 2.5, 3.5, 4.5])
upper_bound = np.array([1.5, 2.5, 3.5, 4.5, 5.5])
coverage = calculate_coverage(y_true, lower_bound, upper_bound)
print(coverage == 1.0)