File size: 1,706 Bytes
d47b5a6
72ac970
 
 
 
 
 
1f331a4
d47b5a6
72ac970
d47b5a6
 
 
 
72ac970
 
 
 
1f331a4
 
 
72ac970
1f331a4
72ac970
 
 
1f331a4
 
72ac970
 
 
1f331a4
72ac970
 
 
1f331a4
 
 
 
 
 
 
 
 
 
 
 
 
 
72ac970
 
 
1f331a4
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
---
title: ECE
datasets:
-  
tags:
- evaluate
- metric
description: "Expected calibration error (ECE)"
sdk: gradio
sdk_version: 3.19.1
app_file: app.py
pinned: false
---

# Metric Card for ECE

## Metric Description

This metrics computes the expected calibration error (ECE).
It directly calls the torchmetrics package:
https://torchmetrics.readthedocs.io/en/stable/classification/calibration_error.html

## How to Use

### Inputs
*List all input arguments in the format below*
- **input_field** *(tensor or numpy array, float32): predictions (after softmax). They must have a shape (N,C,...) if multiclass, or (N,...) if binary.*
- **references** *(tensor or numpy array, int64): reference for each prediction, with a shape (N,...).*

### Output Values

ECE as float.

### Examples

```Python
ce = evaluate.load("Natooz/ece")
results = ece.compute(
    references=np.array([[0.25, 0.20, 0.55],
                         [0.55, 0.05, 0.40],
                         [0.10, 0.30, 0.60],
                         [0.90, 0.05, 0.05]]),
    predictions=np.array(),
    num_classes=3,
    n_bins=3,
    norm="l1",
)
print(results)
```

## Citation

```bibtex
@inproceedings{NEURIPS2019_f8c0c968,
     author = {Kumar, Ananya and Liang, Percy S and Ma, Tengyu},
     booktitle = {Advances in Neural Information Processing Systems},
     editor = {H. Wallach and H. Larochelle and A. Beygelzimer and F. d\textquotesingle Alch\'{e}-Buc and E. Fox and R. Garnett},
     publisher = {Curran Associates, Inc.},
     title = {Verified Uncertainty Calibration},
     url = {https://papers.nips.cc/paper_files/paper/2019/hash/f8c0c968632845cd133308b1a494967f-Abstract.html},
     volume = {32},
     year = {2019}
}
```