Skip to content

Commit

Permalink
Added quantile interval score
Browse files Browse the repository at this point in the history
  • Loading branch information
reza-armuei committed Sep 27, 2024
1 parent f15cfe4 commit 59c465e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/scores/continuous/interval_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
import xarray as xr

from scores.functions import apply_weights
from scores.typing import FlexibleDimensionTypes, XarrayLike
from scores.typing import FlexibleDimensionTypes
from scores.utils import check_dims, gather_dimensions


def quantile_interval_score( # pylint: disable=R0914
fcst_lower_qtile: XarrayLike,
fcst_upper_qtile: XarrayLike,
obs: XarrayLike,
fcst_lower_qtile: xr.DataArray,
fcst_upper_qtile: xr.DataArray,
obs: xr.DataArray,
lower_qtile_level: float,
upper_qtile_level: float,
*, # Force keywords arguments to be keyword-only
reduce_dims: Optional[FlexibleDimensionTypes] = None,
preserve_dims: Optional[FlexibleDimensionTypes] = None,
weights: Optional[XarrayLike] = None,
weights: Optional[xr.DataArray] = None,
) -> xr.Dataset:
"""
Calculates the qauntile interval score for interval forecasts. This score penalizes
Expand Down Expand Up @@ -65,9 +65,10 @@ def quantile_interval_score( # pylint: disable=R0914
estimation", J. Amer. Stat. Assoc., Vol. 102 No. 477 (2007), pp. 359--378,
Corollary 5.2.
"""

if not 0 < lower_qtile_level < upper_qtile_level < 1:
raise ValueError(
"Expected 0 < lower_qtile_level < upper_qtile_level < 1. But got"
"Expected 0 < lower_qtile_level < upper_qtile_level < 1. But got "
f"lower_qtile_level = {lower_qtile_level} and upper_qtile_level = {upper_qtile_level}"
)
# Check fcst_lower_qtile and fcst_upper_qtile have the same dimension
Expand Down

0 comments on commit 59c465e

Please sign in to comment.