lhy commited on
Commit
f57360c
·
1 Parent(s): e5763da
Files changed (1) hide show
  1. hamming_loss.py +6 -6
hamming_loss.py CHANGED
@@ -15,6 +15,7 @@
15
 
16
  import evaluate
17
  import datasets
 
18
 
19
 
20
  # TODO: Add BibTeX citation
@@ -54,7 +55,7 @@ Examples:
54
  """
55
 
56
  # TODO: Define external resources urls if needed
57
- BAD_WORDS_URL = "http://url/to/external/resource/bad_words.txt"
58
 
59
 
60
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
@@ -75,10 +76,10 @@ class HammingLoss(evaluate.Metric):
75
  'references': datasets.Value('int64'),
76
  }),
77
  # Homepage of the module for documentation
78
- homepage="http://module.homepage",
79
  # Additional links to the codebase or references
80
- codebase_urls=["http://github.com/path/to/codebase/of/new_module"],
81
- reference_urls=["http://path.to.reference.url/new_module"]
82
  )
83
 
84
  def _download_and_prepare(self, dl_manager):
@@ -89,7 +90,6 @@ class HammingLoss(evaluate.Metric):
89
  def _compute(self, predictions, references):
90
  """Returns the scores"""
91
  # TODO: Compute the different scores of the module
92
- accuracy = sum(i == j for i, j in zip(predictions, references)) / len(predictions)
93
  return {
94
- "accuracy": accuracy,
95
  }
 
15
 
16
  import evaluate
17
  import datasets
18
+ from sklearn.metrics import hamming_loss
19
 
20
 
21
  # TODO: Add BibTeX citation
 
55
  """
56
 
57
  # TODO: Define external resources urls if needed
58
+ # BAD_WORDS_URL = "http://url/to/external/resource/bad_words.txt"
59
 
60
 
61
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
 
76
  'references': datasets.Value('int64'),
77
  }),
78
  # Homepage of the module for documentation
79
+ # homepage="http://module.homepage",
80
  # Additional links to the codebase or references
81
+ # codebase_urls=["http://github.com/path/to/codebase/of/new_module"],
82
+ # reference_urls=["http://path.to.reference.url/new_module"]
83
  )
84
 
85
  def _download_and_prepare(self, dl_manager):
 
90
  def _compute(self, predictions, references):
91
  """Returns the scores"""
92
  # TODO: Compute the different scores of the module
 
93
  return {
94
+ "hamming_loss": hamming_loss(references, predictions),
95
  }