## RiskCoverage


Container for risk-coverage results.


Usage

``` python
RiskCoverage(
    coverage,
    threshold,
    risk,
    reference,
    excess,
    risk_type,
    auc_empirical,
    auc_reference,
    auc_excess
)
```


Holds the coverage, score thresholds, empirical and reference risk curves, their difference (excess), and AUC metrics.


## Attributes


`coverage: torch.Tensor`  
Coverage values in `[0, 1]`.

`threshold: torch.Tensor`  
Sorted score thresholds used to compute coverage.

`risk: torch.Tensor`  
Empirical risk at each coverage level.

`reference: torch.Tensor`  
Reference (optimal) risk at each coverage level.

`excess: torch.Tensor`  
Excess risk (empirical - reference).

`risk_type: str`  
Either `'generalized'` or `'selective'`; see `risk_coverage`.

`auc_empirical: torch.Tensor`  
Area under the empirical risk curve (trapezoidal rule).

`auc_reference: torch.Tensor`  
Area under the reference risk curve (trapezoidal rule).

`auc_excess: torch.Tensor`  
Area under the excess risk curve (trapezoidal rule).


## See Also

[RiskCoverageMetric](RiskCoverageMetric.md#seapig.RiskCoverageMetric)  
Metric wrapper for use with Lightning.


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Create a [RiskCoverage](RiskCoverage.md#seapig.RiskCoverage) container. |
| [__repr__()](#__repr__) | Short representation including AUCs and number of points. |
| [plot()](#plot) | Return a matplotlib Figure with the requested curves. |

------------------------------------------------------------------------


#### \_\_init\_\_()


Create a [RiskCoverage](RiskCoverage.md#seapig.RiskCoverage) container.


Usage

``` python
__init__(
    coverage,
    threshold,
    risk,
    reference,
    excess,
    risk_type,
    auc_empirical,
    auc_reference,
    auc_excess
)
```


All parameters correspond directly to the attributes of the same name. Typically constructed by `risk_coverage` rather than directly.


------------------------------------------------------------------------


#### \_\_repr\_\_()


Short representation including AUCs and number of points.


Usage

``` python
__repr__()
```


------------------------------------------------------------------------


#### plot()


Return a matplotlib Figure with the requested curves.


Usage

``` python
plot(empirical=True, reference=True, excess=True, digits=4)
```


##### Parameters


`empirical: bool = ``True`  
Whether to include each curve in the plot.

`reference: bool = ``True`  
Whether to include each curve in the plot.

`excess: bool = ``True`  
Whether to include each curve in the plot.

`digits: int = ``4`  
Number of decimal places to show for AUC values in the legend.


##### Returns


`matplotlib.figure.Figure`  
A figure containing the plotted curves.


##### Raises


`ImportError`  
If `matplotlib` is not installed.

`ValueError`  
If all curve flags are False.


##### Examples

``` python
fig = rc.plot(empirical=True, reference=False)
```
