danieldux commited on
Commit
17ea6af
1 Parent(s): fcd15ea

Refactor ISCO hierarchy creation and update metric calculation***

Browse files
Files changed (1) hide show
  1. metric_template_1.py +4 -7
metric_template_1.py CHANGED
@@ -94,10 +94,8 @@ class MetricTemplate1(evaluate.Metric):
94
 
95
  # Download and prepare the ISCO structure csv file
96
  isco_csv = dl_manager.download_and_extract(ISCO_CSV_URL)
97
- isco_json = dl_manager.download_and_extract(ISCO_JSON_URL)
98
  print(f"ISCO CSV file downloaded")
99
- # self.isco_hierarchy = isco.create_hierarchy_dict(isco_csv)
100
- self.isco_hierarchy = isco.create_hierarchy_tree(isco_json)
101
  print("ISCO hierarchy dictionary created")
102
  print(self.isco_hierarchy)
103
 
@@ -119,11 +117,10 @@ class MetricTemplate1(evaluate.Metric):
119
  # true_labels = [{'G'}]
120
  # predicted_labels = [{'F'}]
121
  hierarchy = self.isco_hierarchy
122
- tree, code_to_node = isco.create_hierarchy_tree(hierarchy)
123
- hP, hR, hF = ham.calculate_hierarchical_measures(
124
- references, predictions, tree, code_to_node
125
  )
126
- # hF = ham.hierarchical_f_measure(hP, hR)
127
  print(
128
  f"Hierarchical Precision: {hP}, Hierarchical Recall: {hR}, Hierarchical F-measure: {hF}"
129
  )
 
94
 
95
  # Download and prepare the ISCO structure csv file
96
  isco_csv = dl_manager.download_and_extract(ISCO_CSV_URL)
 
97
  print(f"ISCO CSV file downloaded")
98
+ self.isco_hierarchy = isco.create_hierarchy_dict(isco_csv)
 
99
  print("ISCO hierarchy dictionary created")
100
  print(self.isco_hierarchy)
101
 
 
117
  # true_labels = [{'G'}]
118
  # predicted_labels = [{'F'}]
119
  hierarchy = self.isco_hierarchy
120
+ hP, hR = ham.calculate_hierarchical_precision_recall(
121
+ references, predictions, hierarchy
 
122
  )
123
+ hF = ham.hierarchical_f_measure(hP, hR)
124
  print(
125
  f"Hierarchical Precision: {hP}, Hierarchical Recall: {hR}, Hierarchical F-measure: {hF}"
126
  )