Skip to content

QuantileResidual

yohou.metrics.conformity.QuantileResidual

Bases: BaseConformityScorer

Quantile residual scorer for interval forecasts.

Abstract base class for quantile-based conformity scoring. Subclasses must implement the score method to compute residuals between observed values and predicted interval bounds.

Notes

Unlike Residual and GammaResidual, this scorer operates on interval predictions (lower/upper bounds) rather than point predictions. The prediction_type tag is set to "interval".

See Also

Source Code

Show/Hide source
class QuantileResidual(BaseConformityScorer):
    """Quantile residual scorer for interval forecasts.

    Abstract base class for quantile-based conformity scoring.
    Subclasses must implement the ``score`` method to compute
    residuals between observed values and predicted interval bounds.

    Notes
    -----
    Unlike ``Residual`` and ``GammaResidual``, this scorer operates on
    interval predictions (lower/upper bounds) rather than point predictions.
    The ``prediction_type`` tag is set to ``"interval"``.

    See Also
    --------
    - [`AbsoluteQuantileResidual`][yohou.metrics.conformity.AbsoluteQuantileResidual] : Absolute variant of quantile residuals.
    - [`Residual`][yohou.metrics.conformity.Residual] : Point-prediction conformity scorer.

    """

    def __sklearn_tags__(self):
        """Get the tags for this estimator."""
        tags = super().__sklearn_tags__()
        assert tags.scorer_tags is not None
        tags.scorer_tags.prediction_type = "interval"
        return tags

    @abc.abstractmethod
    def score(self, y_truth: pl.DataFrame, y_pred: pl.DataFrame, /, **score_params) -> pl.DataFrame:
        """Compute quantile residual scores."""

Methods

__sklearn_tags__()

Get the tags for this estimator.

Source Code
Show/Hide source
def __sklearn_tags__(self):
    """Get the tags for this estimator."""
    tags = super().__sklearn_tags__()
    assert tags.scorer_tags is not None
    tags.scorer_tags.prediction_type = "interval"
    return tags

score(y_truth, y_pred, /, **score_params) abstractmethod

Compute quantile residual scores.

Source Code
Show/Hide source
@abc.abstractmethod
def score(self, y_truth: pl.DataFrame, y_pred: pl.DataFrame, /, **score_params) -> pl.DataFrame:
    """Compute quantile residual scores."""