jordyvl commited on
Commit
9182e7b
1 Parent(s): c890236
Files changed (1) hide show
  1. ece.py +16 -8
ece.py CHANGED
@@ -44,20 +44,30 @@ Args:
44
  should be a string with tokens separated by spaces.
45
  references: list of reference for each prediction. Each
46
  reference should be a string with tokens separated by spaces.
 
 
 
 
 
 
 
 
 
 
47
 
48
 
49
 
50
- Returns:
51
- accuracy: description of the first score,
52
- another_score: description of the second score,
53
  Examples:
54
  Examples should be written in doctest format, and should illustrate how
55
  to use the function.
56
 
57
- >>> my_new_module = evaluate.load("my_new_module")
58
- >>> results = my_new_module.compute(references=[0, 1], predictions=[0, 1])
59
  >>> print(results)
60
- {'accuracy': 1.0}
61
  """
62
 
63
  # TODO: Define external resources urls if needed
@@ -200,9 +210,7 @@ class ECE(evaluate.EvaluationModule):
200
  """
201
 
202
  def __init__(self, n_bins=10, bin_range=None, scheme="equal-range", proxy="upper-edge", p=1):
203
- #super().__init__(self)
204
  super().__init__()
205
-
206
  self.n_bins = n_bins
207
  self.bin_range = bin_range
208
  self.scheme = scheme
 
44
  should be a string with tokens separated by spaces.
45
  references: list of reference for each prediction. Each
46
  reference should be a string with tokens separated by spaces.
47
+ y_true : array-like
48
+ Ground truth labels.
49
+ p_hat : array-like
50
+ Array of confidence estimates.
51
+ n_bins : int, default=15
52
+ Number of bins of :math:`[\\frac{1}{n_{\\text{classes}},1]` for the confidence estimates.
53
+ n_classes : int default=None
54
+ Number of classes. Estimated from `y` and `y_pred` if not given.
55
+ p : int, default=1
56
+ Power of the calibration error, :math:`1 \\leq p \\leq \\infty`.
57
 
58
 
59
 
60
+ Returns
61
+ Expected calibration error (ECE), float.
62
+
63
  Examples:
64
  Examples should be written in doctest format, and should illustrate how
65
  to use the function.
66
 
67
+ >>> my_new_module = evaluate.load("jordyvl/ece")
68
+ >>> results = my_new_module.compute(references=[0, 1, 2], predictions=[[0.6, 0.2, 0.2], [0, 0.95, 0.05], [0.7, 0.1 ,0.2]])
69
  >>> print(results)
70
+ {'ECE': 1.0}
71
  """
72
 
73
  # TODO: Define external resources urls if needed
 
210
  """
211
 
212
  def __init__(self, n_bins=10, bin_range=None, scheme="equal-range", proxy="upper-edge", p=1):
 
213
  super().__init__()
 
214
  self.n_bins = n_bins
215
  self.bin_range = bin_range
216
  self.scheme = scheme