Uncertainty Diagnostics¶
The default uncertainty diagnostics preserve numerical NaN values for
legitimate undefined edge cases, such as uncertainty-error correlation when all
predictive standard deviations are constant. Use the JSON-safe helpers for API
payloads, dashboards, and report manifests that require strict JSON.
matgpr.uncertainty
¶
prediction_interval_bounds(y_pred, y_std, *, confidence_level=0.95)
¶
Return Gaussian predictive interval bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_pred
|
Predictive mean values. |
required | |
y_std
|
Predictive standard deviations in the same units as |
required | |
confidence_level
|
float
|
Central interval probability, for example |
0.95
|
Source code in matgpr/uncertainty.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
interval_coverage(y_true, y_pred, y_std, *, confidence_level=0.95)
¶
Calculate observed coverage for a Gaussian prediction interval.
Source code in matgpr/uncertainty.py
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 | |
calibration_curve(y_true, y_pred, y_std, *, confidence_levels=None)
¶
Calculate observed coverage across confidence levels.
The returned dataframe is useful for calibration plots. A well-calibrated uncertainty model should have observed coverage close to expected coverage across the full range of confidence levels.
Source code in matgpr/uncertainty.py
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 | |
gaussian_nlpd(y_true, y_pred, y_std, *, min_std=1e-12, reduction='mean')
¶
Calculate Gaussian negative log predictive density.
Lower values indicate sharper and better-calibrated predictive
distributions. reduction="none" returns one NLPD value per sample.
Source code in matgpr/uncertainty.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
standardized_residuals(y_true, y_pred, y_std)
¶
Return residuals divided by predictive standard deviation.
Source code in matgpr/uncertainty.py
143 144 145 146 | |
uncertainty_error_correlation(y_true, y_pred, y_std, *, method='spearman')
¶
Correlate predictive standard deviation with absolute prediction error.
Source code in matgpr/uncertainty.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
uncertainty_diagnostics(y_true, y_pred, y_std, *, confidence_level=0.95)
¶
Return a compact dictionary of uncertainty diagnostic metrics.
Source code in matgpr/uncertainty.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
json_safe_diagnostics(diagnostics, *, include_warnings=True, warning_key='diagnostic_warnings')
¶
Return strict-JSON-safe uncertainty diagnostics.
Undefined diagnostic values, such as uncertainty-error correlation for
constant uncertainties, are converted from NaN to None.
Source code in matgpr/uncertainty.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
json_safe_uncertainty_diagnostics(y_true, y_pred, y_std, *, confidence_level=0.95, include_warnings=True, warning_key='diagnostic_warnings')
¶
Calculate uncertainty diagnostics and return a strict-JSON-safe dictionary.
Source code in matgpr/uncertainty.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |