def checkPrediction2(self, patternNZs, output=None, confidence=None,
                      details=False):

    """
    This function will replace checkPrediction.

    This function produces goodness-of-match scores for a set of input patterns, by
    checking for their presense in the current and predicted output of the TP.
    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 TP's prediction.

    todo: Add option to check predictedState only.

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


    Return value:
    ============
    The following list is returned:

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

    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

    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

    conf_i            the confidence score for the i'th pattern in patternsToCheck

    missing_i         the bits in the i'th pattern that were missing
                      in the output. This list is only returned if details is
                      True.
    """


    # Get the non-zeros in each pattern
    numPatterns = len(patternNZs)

    # Compute the union of all the expected patterns
    orAll = set()
    orAll = orAll.union(*patternNZs)

    # Get the list of active columns in the output
    if output is None:
      assert self.currentOutput is not None
      output = self.currentOutput
    output = set(output.sum(axis=1).nonzero()[0])

    # Compute the total extra and missing in the output
    totalExtras = len(output.difference(orAll))
    totalMissing = len(orAll.difference(output))

    # Get the percent confidence level per column by summing the confidence levels
    #  of the cells in the column. During training, each segment's confidence
    #  number is computed as a running average of how often it correctly
    #  predicted bottom-up activity on that column. A cell's confidence number
    #  is taken from the first active segment found in the cell. Note that
    #  confidence will only be non-zero for predicted columns.
    if confidence is None:
      confidence = self.confidence['t']
    # Set the column confidence to be the max of the cell confidences in that
    #  column.
    colConfidence   = self.columnConfidences(confidence)


    # Assign confidences to each pattern
    confidences = []
    for i in xrange(numPatterns):
      # Sum of the column confidences for this pattern
      positivePredictionSum = colConfidence[patternNZs[i]].sum()
      # How many columns in this pattern
      positiveColumnCount   = len(patternNZs[i])

      # Sum of all the column confidences
      totalPredictionSum    = colConfidence.sum()
      # Total number of columns
      totalColumnCount      = len(colConfidence)

      negativePredictionSum = totalPredictionSum - positivePredictionSum
      negativeColumnCount   = totalColumnCount   - positiveColumnCount

      # Compute the average confidence score per column for this pattern
      if positiveColumnCount != 0:
        positivePredictionScore = positivePredictionSum/positiveColumnCount
      else:
        positivePredictionScore = 0.0

      # Compute the average confidence score per column for the other patterns
      if negativeColumnCount != 0:
        negativePredictionScore = negativePredictionSum/negativeColumnCount
      else:
        negativePredictionScore = 0.0
      predictionScore         = positivePredictionScore - negativePredictionScore

      confidences.append((predictionScore,
                          positivePredictionScore,
                          negativePredictionScore))

    # Include detail? (bits in each pattern that were missing from the output)
    if details:
      missingPatternBits = [set(pattern).difference(output) \
                                  for pattern in patternNZs]

      return (totalExtras, totalMissing, confidences, missingPatternBits)
    else:
      return (totalExtras, totalMissing, confidences)
This function will replace checkPrediction.

    This function produces goodness-of-match scores for a set of input patterns, by
    checking for their presense in the current and predicted output of the TP.
    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 TP's prediction.

    todo: Add option to check predictedState only.

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


    Return value:
    ============
    The following list is returned:

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

    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

    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

    conf_i            the confidence score for the i'th pattern in patternsToCheck

    missing_i         the bits in the i'th pattern that were missing
                      in the output. This list is only returned if details is
                      True.