def _checkPrediction(self, patternNZs, output=None, colConfidence=None,<EOL>details=False):
<EOL>numPatterns = len(patternNZs)<EOL>orAll = set()<EOL>orAll = orAll.union(*patternNZs)<EOL>if output is None:<EOL><INDENT>assert self.currentOutput is not None<EOL>output = self.currentOutput<EOL><DEDENT>output = set(output.sum(axis=<NUM_LIT:1>).nonzero()[<NUM_LIT:0>])<EOL>totalExtras = len(output.difference(orAll))<EOL>totalMissing = len(orAll.difference(output))<EOL>if colConfidence is None:<EOL><INDENT>colConfidence = self.colConfidence['<STR_LIT:t>']<EOL><DEDENT>confidences = []<EOL>for i in range(numPatterns):<EOL><INDENT>positivePredictionSum = colConfidence[patternNZs[i]].sum()<EOL>positiveColumnCount   = len(patternNZs[i])<EOL>totalPredictionSum    = colConfidence.sum()<EOL>totalColumnCount      = len(colConfidence)<EOL>negativePredictionSum = totalPredictionSum - positivePredictionSum<EOL>negativeColumnCount   = totalColumnCount   - positiveColumnCount<EOL>if positiveColumnCount != <NUM_LIT:0>:<EOL><INDENT>positivePredictionScore = positivePredictionSum<EOL><DEDENT>else:<EOL><INDENT>positivePredictionScore = <NUM_LIT:0.0><EOL><DEDENT>if negativeColumnCount != <NUM_LIT:0>:<EOL><INDENT>negativePredictionScore = negativePredictionSum<EOL><DEDENT>else:<EOL><INDENT>negativePredictionScore = <NUM_LIT:0.0><EOL><DEDENT>currentSum = negativePredictionScore + positivePredictionScore<EOL>if currentSum > <NUM_LIT:0>:<EOL><INDENT>positivePredictionScore *= <NUM_LIT:1.0>/currentSum<EOL>negativePredictionScore *= <NUM_LIT:1.0>/currentSum<EOL><DEDENT>predictionScore = positivePredictionScore - negativePredictionScore<EOL>confidences.append((predictionScore,<EOL>positivePredictionScore,<EOL>negativePredictionScore))<EOL><DEDENT>if details:<EOL><INDENT>missingPatternBits = [set(pattern).difference(output)<EOL>for pattern in patternNZs]<EOL>return (totalExtras, totalMissing, confidences, missingPatternBits)<EOL><DEDENT>else:<EOL><INDENT>return (totalExtras, totalMissing, confidences)<EOL><DEDENT>
This function produces goodness-of-match scores for a set of input patterns,
by checking for their presence in the current and predicted output of the
TM. Returns a global count of the number of extra and missing bits, the
confidence scores for each input pattern, and (if requested) the
bits in each input pattern that were not present in the TM's prediction.

:param patternNZs a list of input patterns that we want to check for. Each
                  element is a list of the non-zeros in that pattern.
:param output     The output of the TM. If not specified, then use the
                  TM's current output. This can be specified if you are
                  trying to check the prediction metric for an output from
                  the past.
:param colConfidence The column confidences. If not specified, then use the
                     TM's current self.colConfidence. This can be specified if you
                     are trying to check the prediction metrics for an output
                     from the past.
:param details    if True, also include details of missing bits per pattern.

:returns:  list containing:

          [
            totalExtras,
            totalMissing,
            [conf_1, conf_2, ...],
            [missing1, missing2, ...]
          ]

@retval totalExtras a global count of the number of 'extras', i.e. bits that
                    are on in the current output but not in the or of all the
                    passed in patterns
@retval totalMissing a global count of all the missing bits, i.e. the bits
                     that are on in the or of the patterns, but not in the
                     current output
@retval conf_i the confidence score for the i'th pattern inpatternsToCheck
               This consists of 3 items as a tuple:
               (predictionScore, posPredictionScore, negPredictionScore)
@retval missing_i the bits in the i'th pattern that were missing
                  in the output. This list is only returned if details is
                  True.