danieldux commited on
Commit
2053ce2
1 Parent(s): 3f5c862

Refactor ISCO_Hierarchical_Accuracy methods to use self parameter

Browse files
Files changed (1) hide show
  1. isco_hierarchical_accuracy.py +4 -3
isco_hierarchical_accuracy.py CHANGED
@@ -112,7 +112,7 @@ class ISCO_Hierarchical_Accuracy(evaluate.Metric):
112
  reference_urls=["http://path.to.reference.url/new_module"],
113
  )
114
 
115
- def create_hierarchy_dict(file: str) -> dict:
116
  """
117
  Creates a dictionary where keys are nodes and values are sets of parent nodes representing the group level hierarchy of the ISCO-08 structure.
118
  The function assumes that the input CSV file has a column named 'unit' with the 4-digit ISCO-08 codes.
@@ -150,7 +150,7 @@ class ISCO_Hierarchical_Accuracy(evaluate.Metric):
150
 
151
  return isco_hierarchy
152
 
153
- def find_ancestors(node: str, hierarchy: dict) -> set:
154
  """
155
  Find the ancestors of a given node in a hierarchy.
156
 
@@ -189,6 +189,7 @@ class ISCO_Hierarchical_Accuracy(evaluate.Metric):
189
  return extended_classes
190
 
191
  def calculate_hierarchical_precision_recall(
 
192
  reference_codes: List[str],
193
  predicted_codes: List[str],
194
  hierarchy: Dict[str, Set[str]],
@@ -228,7 +229,7 @@ class ISCO_Hierarchical_Accuracy(evaluate.Metric):
228
 
229
  return hP, hR
230
 
231
- def hierarchical_f_measure(hP, hR, beta=1.0):
232
  """
233
  Calculate the hierarchical F-measure.
234
 
 
112
  reference_urls=["http://path.to.reference.url/new_module"],
113
  )
114
 
115
+ def create_hierarchy_dict(self, file: str) -> dict:
116
  """
117
  Creates a dictionary where keys are nodes and values are sets of parent nodes representing the group level hierarchy of the ISCO-08 structure.
118
  The function assumes that the input CSV file has a column named 'unit' with the 4-digit ISCO-08 codes.
 
150
 
151
  return isco_hierarchy
152
 
153
+ def find_ancestors(self, node: str, hierarchy: dict) -> set:
154
  """
155
  Find the ancestors of a given node in a hierarchy.
156
 
 
189
  return extended_classes
190
 
191
  def calculate_hierarchical_precision_recall(
192
+ self,
193
  reference_codes: List[str],
194
  predicted_codes: List[str],
195
  hierarchy: Dict[str, Set[str]],
 
229
 
230
  return hP, hR
231
 
232
+ def hierarchical_f_measure(self, hP, hR, beta=1.0):
233
  """
234
  Calculate the hierarchical F-measure.
235