def convert_label_to_int(doc): return int(doc["label"]) def macro_f1_score(items): from sklearn.metrics import f1_score unzipped_list = list(zip(*items)) golds = unzipped_list[0] preds = unzipped_list[1] fscore = f1_score(golds, preds, average="macro") return fscore