forecaster.metrics.calculate_coverage
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.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| y_true | np.ndarray | pd.Series | True values of the target variable. | required |
| lower_bound | np.ndarray | pd.Series | Lower bound of the interval. | required |
| upper_bound | np.ndarray | pd.Series | Upper bound of the interval. | required |
Returns
| Name | Type | Description |
|---|---|---|
| float | Coverage of the interval. |
Examples
>>> from spotforecast2.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)
>>> coverage == 1.0 # All values within bounds
True