scoring
scoring
¶
ElementaryScore
¶
Elementary scoring function.
The smaller the better.
The elementary scoring function is consistent for the specified functional
for
all values of eta
and is the main ingredient for Murphy diagrams.
See Notes for further details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eta |
float
|
Free parameter. |
required |
functional |
str
|
The functional that is induced by the identification function
|
'mean'
|
level |
float
|
The level of the expectile of quantile. (Often called \(\alpha\).)
It must be |
0.5
|
Notes
The elementary scoring or loss function is given by The elementary scoring or loss function is given by
with identification functions
\(V\) for the given functional
\(T\) . If allows for the mixture or Choquet
representation
for some locally finite measure \(H\). It follows that the scoring function \(S\) is consistent for \(T\).
References
[Jordan2022]
-
A.I. Jordan, A. Mühlemann, J.F. Ziegel. "Characterizing the optimal solutions to the isotonic regression problem for identifiable functionals". (2022) doi:10.1007/s10463-021-00808-0
[GneitingResin2022]
-
T. Gneiting, J. Resin. "Regression Diagnostics meets Forecast Evaluation: Conditional Calibration, Reliability Diagrams, and Coefficient of Determination". arxiv:2108.03210
Examples:
>>> el_score = ElementaryScore(eta=2, functional="mean")
>>> el_score(y_obs=[1, 2, 2, 1], y_pred=[4, 1, 2, 3])
0.5
Source code in src/model_diagnostics/scoring/scoring.py
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
|
__call__(y_obs, y_pred, weights=None)
¶
Mean or average score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
Returns:
Name | Type | Description |
---|---|---|
score |
float
|
The average score. |
Source code in src/model_diagnostics/scoring/scoring.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
score_per_obs(y_obs, y_pred)
¶
Score per observation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
Returns:
Name | Type | Description |
---|---|---|
score_per_obs |
ndarray
|
Values of the scoring function for each observation. |
Source code in src/model_diagnostics/scoring/scoring.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
|
GammaDeviance
¶
Gamma deviance.
The smaller the better, minimum is zero.
The Gamma deviance is strictly consistent for the mean.
It has a degree of homogeneity of 0 and is therefore insensitive to a change of
units or multiplication of y_obs
and y_pred
by the same positive constant.
Attributes:
Name | Type | Description |
---|---|---|
functional |
str
|
"mean" |
Notes
\(S(y, z) = 2(\frac{y}{z} -\log\frac{y}{z} - 1)\)
Examples:
>>> gd = GammaDeviance()
>>> gd(y_obs=[3, 2, 1, 1], y_pred=[2, 1, 1 , 2])
0.2972674459459178
Source code in src/model_diagnostics/scoring/scoring.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
__call__(y_obs, y_pred, weights=None)
¶
Mean or average score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
Returns:
Name | Type | Description |
---|---|---|
score |
float
|
The average score. |
Source code in src/model_diagnostics/scoring/scoring.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
score_per_obs(y_obs, y_pred)
¶
Score per observation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
Returns:
Name | Type | Description |
---|---|---|
score_per_obs |
ndarray
|
Values of the scoring function for each observation. |
Source code in src/model_diagnostics/scoring/scoring.py
163 164 165 166 167 168 169 170 171 172 173 174 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
HomogeneousExpectileScore
¶
Homogeneous scoring function of degree h for expectiles.
The smaller the better, minimum is zero.
Up to a multiplicative constant, these are the only scoring functions that are strictly consistent for expectiles at level alpha and homogeneous functions. The possible additive constant is chosen such that the minimal function value equals zero.
Note that the ½-expectile (level alpha=0.5) equals the mean.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
degree |
float
|
Degree of homogeneity. |
2
|
level |
float
|
The level of the expectile. (Often called \(\alpha\).)
It must be |
0.5
|
Attributes:
Name | Type | Description |
---|---|---|
functional |
str
|
"mean" if |
Notes
The homogeneous score of degree \(h\) is given by
Note that the first term, \(2 |\mathbf{1}\{z \ge y\} - \alpha|\) equals 1 for \(\alpha=0.5\). There are important domain restrictions and limits:
-
\(h>1\): All real numbers \(y\) and \(z\) are allowed.
Special case \(h=2, \alpha=\frac{1}{2}\) equals the squared error, aka Normal deviance \(S(y, z) = (y - z)^2\).
-
\(0 < h \leq 1\): Only \(y \geq 0\), \(z>0\) are allowed.
Special case \(h=1, \alpha=\frac{1}{2}\) (by taking the limit) equals the Poisson deviance \(S(y, z) = 2(y\log\frac{y}{z} - y + z)\).
-
\(h \leq 0\): Only \(y>0\), \(z>0\) are allowed.
Special case \(h=0, \alpha=\frac{1}{2}\) (by taking the limit) equals the Gamma deviance \(S(y, z) = 2(\frac{y}{z} -\log\frac{y}{z} - 1)\).
For the common domains, \(S_{\frac{1}{2}}^h\) equals the Tweedie deviance with the following relation between the degree of homogeneity \(h\) and the Tweedie power \(p\): \(h = 2-p\).
References
[Gneiting2011]
-
T. Gneiting. "Making and Evaluating Point Forecasts". (2011) doi:10.1198/jasa.2011.r10138 arxiv:0912.0902
Examples:
>>> hes = HomogeneousExpectileScore(degree=2, level=0.1)
>>> hes(y_obs=[0, 0, 1, 1], y_pred=[-1, 1, 1 , 2])
0.95
Source code in src/model_diagnostics/scoring/scoring.py
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
__call__(y_obs, y_pred, weights=None)
¶
Mean or average score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
Returns:
Name | Type | Description |
---|---|---|
score |
float
|
The average score. |
Source code in src/model_diagnostics/scoring/scoring.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
score_per_obs(y_obs, y_pred)
¶
Score per observation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
Returns:
Name | Type | Description |
---|---|---|
score_per_obs |
ndarray
|
Values of the scoring function for each observation. |
Source code in src/model_diagnostics/scoring/scoring.py
163 164 165 166 167 168 169 170 171 172 173 174 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
HomogeneousQuantileScore
¶
Homogeneous scoring function of degree h for quantiles.
The smaller the better, minimum is zero.
Up to a multiplicative constant, these are the only scoring funtions that are strictly consistent for quantiles at level alpha and homogeneous functions. The possible additive constant is chosen such that the minimal function value equals zero.
Note that the ½-quantile (level alpha=0.5) equals the median.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
degree |
float
|
Degree of homogeneity. |
2
|
level |
float
|
The level of the quantile. (Often called \(\alpha\).)
It must be |
0.5
|
Attributes:
Name | Type | Description |
---|---|---|
functional |
str
|
"quantile" |
Notes
The homogeneous score of degree \(h\) is given by
There are important domain restrictions and limits:
-
\(h\) positive odd integer: All real numbers \(y\) and \(z\) are allowed.
- Special case \(h=1\) equals the pinball loss, \(S(y, z) = (\mathbf{1}\{z \ge y\} - \alpha) (z - y)\).
- Special case \(h=1, \alpha=\frac{1}{2}\) equals half the absolute error \(S(y, z) = \frac{1}{2}|z - y|\).
-
\(h\) real valued: Only \(y>0\), \(z>0\) are allowed.
Special case \(h=0\) (by taking the limit) equals \(S(y, z) = |\mathbf{1}\{z \ge y\} - \alpha| \log\frac{z}{y}\).
References
[Gneiting2011]
-
T. Gneiting. "Making and Evaluating Point Forecasts". (2011) doi:10.1198/jasa.2011.r10138 arxiv:0912.0902
Examples:
>>> hqs = HomogeneousQuantileScore(degree=3, level=0.1)
>>> hqs(y_obs=[0, 0, 1, 1], y_pred=[-1, 1, 1 , 2])
0.6083333333333334
Source code in src/model_diagnostics/scoring/scoring.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
__call__(y_obs, y_pred, weights=None)
¶
Mean or average score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
Returns:
Name | Type | Description |
---|---|---|
score |
float
|
The average score. |
Source code in src/model_diagnostics/scoring/scoring.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
score_per_obs(y_obs, y_pred)
¶
Score per observation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
Returns:
Name | Type | Description |
---|---|---|
score_per_obs |
ndarray
|
Values of the scoring function for each observation. |
Source code in src/model_diagnostics/scoring/scoring.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
LogLoss
¶
Log loss.
The smaller the better, minimum is zero.
The log loss is a strictly consistent scoring function for the mean for observations and predictions in the range 0 to 1. It is also referred to as (half the) Bernoulli deviance, (half the) Binomial log-likelihood, logistic loss and binary cross-entropy. Its minimal function value is zero.
Attributes:
Name | Type | Description |
---|---|---|
functional |
str
|
"mean" |
Notes
The log loss for \(y,z \in [0,1]\) is given by
If one restricts to \(y\in \{0, 1\}\), this simplifies to
Examples:
>>> ll = LogLoss()
>>> ll(y_obs=[0, 0.5, 1, 1], y_pred=[0.1, 0.2, 0.8 , 0.9], weights=[1, 2, 1, 1])
0.17603033705165635
Source code in src/model_diagnostics/scoring/scoring.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
|
__call__(y_obs, y_pred, weights=None)
¶
Mean or average score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
Returns:
Name | Type | Description |
---|---|---|
score |
float
|
The average score. |
Source code in src/model_diagnostics/scoring/scoring.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
score_per_obs(y_obs, y_pred)
¶
Score per observation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
Returns:
Name | Type | Description |
---|---|---|
score_per_obs |
ndarray
|
Values of the scoring function for each observation. |
Source code in src/model_diagnostics/scoring/scoring.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
|
PinballLoss
¶
Pinball loss.
The smaller the better, minimum is zero.
The pinball loss is strictly consistent for quantiles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level |
float
|
The level of the quantile. (Often called \(\alpha\).)
It must be |
0.5
|
Attributes:
Name | Type | Description |
---|---|---|
functional |
str
|
"quantile" |
Notes
The pinball loss has degree of homogeneity 1 and is given by
The authors do not know where and when the term pinball loss was coined. It is most famously used in quantile regression.
Examples:
>>> pl = PinballLoss(level=0.9)
>>> pl(y_obs=[0, 0, 1, 1], y_pred=[-1, 1, 1 , 2])
0.275
Source code in src/model_diagnostics/scoring/scoring.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
|
__call__(y_obs, y_pred, weights=None)
¶
Mean or average score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
Returns:
Name | Type | Description |
---|---|---|
score |
float
|
The average score. |
Source code in src/model_diagnostics/scoring/scoring.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
score_per_obs(y_obs, y_pred)
¶
Score per observation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
Returns:
Name | Type | Description |
---|---|---|
score_per_obs |
ndarray
|
Values of the scoring function for each observation. |
Source code in src/model_diagnostics/scoring/scoring.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
PoissonDeviance
¶
Poisson deviance.
The smaller the better, minimum is zero.
The Poisson deviance is strictly consistent for the mean. It has a degree of homogeneity of 1.
Attributes:
Name | Type | Description |
---|---|---|
functional |
str
|
"mean" |
Notes
\(S(y, z) = 2(y\log\frac{y}{z} - y + z)\)
Examples:
>>> pd = PoissonDeviance()
>>> pd(y_obs=[0, 0, 1, 1], y_pred=[2, 1, 1 , 2])
1.6534264097200273
Source code in src/model_diagnostics/scoring/scoring.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
__call__(y_obs, y_pred, weights=None)
¶
Mean or average score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
Returns:
Name | Type | Description |
---|---|---|
score |
float
|
The average score. |
Source code in src/model_diagnostics/scoring/scoring.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
score_per_obs(y_obs, y_pred)
¶
Score per observation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
Returns:
Name | Type | Description |
---|---|---|
score_per_obs |
ndarray
|
Values of the scoring function for each observation. |
Source code in src/model_diagnostics/scoring/scoring.py
163 164 165 166 167 168 169 170 171 172 173 174 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
SquaredError
¶
Squared error.
The smaller the better, minimum is zero.
The squared error is strictly consistent for the mean. It has a degree of homogeneity of 2. In the context of probabilistic classification, it is also known as Brier score.
Attributes:
Name | Type | Description |
---|---|---|
functional |
str
|
"mean" |
Notes
\(S(y, z) = (y - z)^2\)
Examples:
>>> se = SquaredError()
>>> se(y_obs=[0, 0, 1, 1], y_pred=[-1, 1, 1 , 2])
0.75
Source code in src/model_diagnostics/scoring/scoring.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
__call__(y_obs, y_pred, weights=None)
¶
Mean or average score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
Returns:
Name | Type | Description |
---|---|---|
score |
float
|
The average score. |
Source code in src/model_diagnostics/scoring/scoring.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
score_per_obs(y_obs, y_pred)
¶
Score per observation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs)
|
Predicted values of the |
required |
Returns:
Name | Type | Description |
---|---|---|
score_per_obs |
ndarray
|
Values of the scoring function for each observation. |
Source code in src/model_diagnostics/scoring/scoring.py
163 164 165 166 167 168 169 170 171 172 173 174 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
decompose(y_obs, y_pred, weights=None, *, scoring_function, functional=None, level=None)
¶
Additive decomposition of scores.
The score is decomposed as
score = miscalibration - discrimination + uncertainty
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. |
required |
y_pred |
array-like of shape (n_obs) or (n_obs, n_models)
|
Predicted values of the |
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
scoring_function |
callable
|
A scoring function with signature roughly
|
required |
functional |
str or None
|
The target functional which
|
None
|
level |
float or None
|
Functionals like expectiles and quantiles have a level (often called alpha).
If |
None
|
Returns:
Name | Type | Description |
---|---|---|
decomposition |
DataFrame
|
The resulting score decomposition as a dataframe with columns:
|
If `y_pred` contains several predictions, i.e. it is 2-dimension with shape
|
|
|
`(n_obs, n_pred)` and `n_pred >1`, then there is the additional column:
|
|
Notes
To be precise, this function returns the decomposition of the score in terms of
auto-miscalibration, auto-discrimination (or resolution) and uncertainy (or
entropy), see [FLM2022]
and references therein.
The key element is to estimate the recalibrated predictions, i.e. \(T(Y|m(X))\) for
the target functional \(T\) and model predictions \(m(X)\).
This is accomplished by isotonic regression, [Dimitriadis2021]
and
[Gneiting2021]
.
References
[FLM2022]
-
T. Fissler, C. Lorentzen, and M. Mayer. "Model Comparison and Calibration Assessment". (2022) arxiv:2202.12780.
[Dimitriadis2021]
-
T. Dimitriadis, T. Gneiting, and A. I. Jordan. "Stable reliability diagrams for probabilistic classifiers". (2021) doi:10.1073/pnas.2016191118
[Gneiting2021]
-
T. Gneiting and J. Resin. "Regression Diagnostics meets Forecast Evaluation: Conditional Calibration, Reliability Diagrams, and Coefficient of Determination". (2021). arXiv:2108.03210.
Examples:
>>> decompose(y_obs=[0, 0, 1, 1], y_pred=[-1, 1, 1, 2],
... scoring_function=SquaredError())
shape: (1, 4)
┌────────────────┬────────────────┬─────────────┬───────┐
│ miscalibration ┆ discrimination ┆ uncertainty ┆ score │
│ --- ┆ --- ┆ --- ┆ --- │
│ f64 ┆ f64 ┆ f64 ┆ f64 │
╞════════════════╪════════════════╪═════════════╪═══════╡
│ 0.625 ┆ 0.125 ┆ 0.25 ┆ 0.75 │
└────────────────┴────────────────┴─────────────┴───────┘
Source code in src/model_diagnostics/scoring/scoring.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
|
plot_murphy_diagram(y_obs, y_pred, weights=None, *, etas=100, functional='mean', level=0.5, ax=None)
¶
Plot a Murphy diagram.
A Murphy diagram plots the scores of elementary scoring functions ElementaryScore
over a range of their free parameter eta
. This shows, if a model dominates all
others over a wide class of scoring functions or if the ranking is very much
dependent on the choice of scoring function.
See Notes for further details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_obs |
array-like of shape (n_obs)
|
Observed values of the response variable. For binary classification, y_obs is expected to be in the interval [0, 1]. |
required |
y_pred |
array-like of shape (n_obs) or (n_obs, n_models)
|
Predicted values, e.g. for the conditional expectation of the response,
|
required |
weights |
array-like of shape (n_obs) or None
|
Case weights. |
None
|
etas |
int or array - like
|
If an integer is given, equidistant points between min and max y values are generater. If an array-like is given, those points are used. |
100
|
functional |
str
|
The functional that is induced by the identification function
|
'mean'
|
level |
float
|
The level of the expectile of quantile. (Often called \(\alpha\).)
It must be |
0.5
|
ax |
Axes
|
Axes object to draw the plot onto, otherwise uses the current Axes. |
None
|
Returns:
Name | Type | Description |
---|---|---|
ax |
Either the matplotlib axes or the plotly figure. This is configurable by
setting the |
References
[Ehm2015]
-
W. Ehm, T. Gneiting, A. Jordan, F. Krüger. "Of Quantiles and Expectiles: Consistent Scoring Functions, Choquet Representations, and Forecast Rankings". arxiv:1503.08195.
Source code in src/model_diagnostics/scoring/plots.py
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|