Visualization¶
reliably.viz.diagrams.reliability_diagram(y_true, y_prob, *, n_bins=15, binning='adaptive', band=True, n_bootstrap=200, seed=0, ax=None, title='Reliability Diagram')
¶
Plot a reliability diagram with optional bootstrap confidence band.
The smooth kernel curve (smECE) is plotted with a shaded bootstrap band. The binned points are overlaid as scatter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_true
|
array - like
|
Integer labels. |
required |
y_prob
|
array - like
|
Probability matrix or binary scores. |
required |
n_bins
|
int
|
Number of bins for the scatter overlay. |
15
|
binning
|
str
|
|
'adaptive'
|
band
|
bool
|
Whether to show the bootstrap confidence band. |
True
|
n_bootstrap
|
int
|
Resamples for the confidence band. |
200
|
seed
|
int
|
RNG seed. |
0
|
ax
|
Axes | None
|
Axes to plot on; creates a new figure if |
None
|
title
|
str
|
Plot title. |
'Reliability Diagram'
|
Returns:
| Type | Description |
|---|---|
Axes
|
|
Examples:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = rng.integers(0, 2, 300)
>>> p = rng.uniform(0, 1, 300)
>>> ax = reliability_diagram(y, p, band=False)
>>> ax is not None
True
Source code in src/reliably/viz/diagrams.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
reliably.viz.diagrams.confidence_histogram(y_prob, *, n_bins=20, ax=None, title='Confidence Histogram')
¶
Plot a histogram of top-label confidence scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_prob
|
array - like
|
Probability matrix or binary scores. |
required |
n_bins
|
int
|
Number of histogram bins. |
20
|
ax
|
Axes | None
|
Axes to plot on. |
None
|
title
|
str
|
Plot title. |
'Confidence Histogram'
|
Returns:
| Type | Description |
|---|---|
Axes
|
|
Examples:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> p = rng.uniform(0, 1, 300)
>>> ax = confidence_histogram(p)
>>> ax is not None
True