parameters: (self)
docstring: Evaluate analogy questions and reports accuracy.
docstring_summary: Evaluate analogy questions and reports accuracy.
docstring_tokens: Evaluate analogy questions and reports accuracy .
function: def eval(self):
      """Evaluate analogy questions and reports accuracy."""
  
      # How many questions we get right at precision@1.
      correct = 0
  
      total = self._analogy_questions.shape[0]
      start = 0
      while start < total:
        limit = start + 2500
        sub = self._analogy_questions[start:limit, :]
        idx = self._predict(sub)
        start = limit
        for question in xrange(sub.shape[0]):
          for j in xrange(4):
            if idx[question, j] == sub[question, 3]:
              # Bingo! We predicted correctly. E.g., [italy, rome, france, paris].
              correct += 1
              break
            elif idx[question, j] in sub[question, :3]:
              # We need to skip words already in the question.
              continue
            else:
              # The correct label is not the precision@1
              break
      print()
      print("Eval %4d/%d accuracy = %4.1f%%" % (correct, total,
                                                correct * 100.0 / total))
function_tokens: def eval ( self ) : # How many questions we get right at precision@1. correct = 0 total = self . _analogy_questions . shape [ 0 ] start = 0 while start < total : limit = start + 2500 sub = self . _analogy_questions [ start : limit , : ] idx = self . _predict ( sub ) start = limit for question in xrange ( sub . shape [ 0 ] ) : for j in xrange ( 4 ) : if idx [ question , j ] == sub [ question , 3 ] : # Bingo! We predicted correctly. E.g., [italy, rome, france, paris]. correct += 1 break elif idx [ question , j ] in sub [ question , : 3 ] : # We need to skip words already in the question. continue else : # The correct label is not the precision@1 break print ( ) print ( "Eval %4d/%d accuracy = %4.1f%%" % ( correct , total , correct * 100.0 / total ) )