Skip to content

Commit

Permalink
f1 score for hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
adelmemariani committed Dec 5, 2023
1 parent 5ed0b38 commit 0dce68f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions chebai/result/box_eval/evals_utility_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import numpy as np
import matplotlib.pyplot as plt

from sklearn.metrics import f1_score
from sklearn.metrics import precision_score
from sklearn.metrics import recall_score
from sklearn import metrics
#-----------------------------------------------------------------


Expand Down Expand Up @@ -155,3 +156,13 @@ def visualize_boxes_3d(boxes, labels, limits):
if CHEBI_ID_i in all_superclasses:
chebi_containment_matrix[idx_j][idx_i] = True


#------------------------------------
#F1 score for hierarchy

y_true = chebi_containment_matrix
y_pred = containment_matrix.astype(bool)

print(precision_score(y_true, y_pred, average="micro"))
print(recall_score(y_true, y_pred, average="micro"))
print(f1_score(y_true, y_pred, average="micro"))

0 comments on commit 0dce68f

Please sign in to comment.