code: def get_conll_scores(predictions, y, y_lex, unk="O"):
      """Get Conll style scores (precision, recall, f1)"""
      if isinstance(predictions, list):
          predictions = predictions[-1]
      test_p = predictions
      if len(test_p.shape) > 2:
          test_p = test_p.argmax(2)
      test_y = y
      if len(test_y.shape) > 2:
          test_y = test_y.argmax(2)
  
      prediction_data = []
      for n in range(test_y.shape[0]):
          test_yval = []
          for i in list(test_y[n]):
              try:
                  test_yval.append(y_lex[i])
              except KeyError:
                  pass
          test_pval = [unk] * len(test_yval)
          for e, i in enumerate(list(test_p[n])[: len(test_pval)]):
              try:
                  test_pval[e] = y_lex[i]
              except KeyError:
                  pass
          prediction_data.append((test_yval, test_pval))
      y_true, y_pred = list(zip(*prediction_data))
      return classification_report(y_true, y_pred, digits=3)
  
file_path: nlp-architect/nlp_architect/utils/metrics.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from scipy.stats import pearsonr, spearmanr
  from sklearn.metrics import f1_score
  from collections import defaultdict
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: get_conll_scores(predictions, y, y_lex, unk) and returns: classification_report