code: def sequence_precision_score(y_true, y_pred, suffix=False):
      """Compute the precision.
  
      The precision is the ratio ``tp / (tp + fp)`` where ``tp`` is the number of
      true positives and ``fp`` the number of false positives. The precision is
      intuitively the ability of the classifier not to label as positive a sample.
  
      The best value is 1 and the worst value is 0.
  
      Args:
          y_true : 2d array. Ground truth (correct) target values.
          y_pred : 2d array. Estimated targets as returned by a tagger.
  
      Returns:
          score : float.
  
      Example:
          >>> from seqeval.metrics import precision_score
          >>> y_true = [['O', 'O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'O'], ['B-PER', 'I-PER', 'O']]
          >>> y_pred = [['O', 'O', 'B-MISC', 'I-MISC', 'I-MISC', 'I-MISC', 'O'],
          >>> ['B-PER', 'I-PER', 'O']]
          >>> precision_score(y_true, y_pred)
          0.50
      """
      true_entities = set(get_entities(y_true, suffix))
      pred_entities = set(get_entities(y_pred, suffix))
  
      nb_correct = len(true_entities & pred_entities)
      nb_pred = len(pred_entities)
  
      score = nb_correct / nb_pred if nb_pred > 0 else 0
  
      return score
  
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 12 for calling a global function with example usage: sequence_precision_score(y_true, y_pred, suffix) and returns: score