class_docstr: Class for evaluating the performance of mapping W
class_docstr_tok: ["Class","for","evaluating","the","performance","of","mapping","W"]
docstr: Takes top_matches generated by tf.nn.top_k and calculates accuracy
  Arguments:
       top_matches: Output of tf.nn.topk_k[1]
docstr_tok: ["Takes","top_matches","generated","by","tf.nn.top_k","and","calculates","accuracy","Arguments",":","top_matches",":","Output","of","tf.nn.topk_k","[","1","]"]
code: def calc_accuracy(self, top_matches):
      """
      Takes top_matches generated by tf.nn.top_k and calculates accuracy
      Arguments:
           top_matches: Output of tf.nn.topk_k[1]
      """
      # Calculate Translation accuracy
      # Accuracy at K
      for k in [1, 5, 10]:
          top_k_matches = top_matches[:, :k]
          # Checks for one match
          one_matching = (top_k_matches == self.tgt_ind[:, None]).sum(1)
          # Checks for multiple translations
          matching = {}
          for i, src_id in enumerate(self.src_ind):
              matching[src_id] = min(
                  matching.get(src_id, 0) + one_matching[i], 1
              )
          precision_at_k = 100 * np.mean(list(matching.values()))
          print(
              "%i source words  - Precision at k = %i: %f"
              % (len(matching), k, precision_at_k)
          )
  
file_path: nlp-architect/examples/crosslingembs/evaluate.py
imports: from __future__ import print_function, division
  import numpy
  import tensorflow
  from nlp_architect.data.fasttext_emb import get_eval_data
label_desc: Use image node_id 8 for calling the Evaluate obj's underlying member method code with example usage: obj.calc_accuracy(top_matches) without return types