def averageSequenceAccuracy(self, minOverlap, maxOverlap,
                              firstStat=0, lastStat=None):
    """
    For each object, decide whether the TM uniquely classified it by checking
    that the number of predictedActive cells are in an acceptable range.
    """
    numCorrectSparsity = 0.0
    numCorrectClassifications = 0.0
    numStats = 0.0

    # For each object or sequence we classify every point or element
    #
    # A sequence element is considered correctly classified only if the number
    # of predictedActive cells is within a reasonable range and if the KNN
    # Classifier correctly classifies the active cell representation as
    # belonging to this sequence.
    #
    # A point on an object is considered correctly classified by the TM if the
    # number of predictedActive cells is within range.
    for stats in self.statistics[firstStat:lastStat]:

      # Keep running total of how often the number of predictedActive cells are
      # in the range.  We always skip the first (unpredictable) count.
      predictedActiveStat = stats["TM PredictedActive C0"][1:]
      TMRepresentationStat = stats["TM Full Representation C0"][1:]
      # print "\n-----------"
      # print stats["object"], predictedActiveStat
      for numCells,sdr in zip(predictedActiveStat, TMRepresentationStat):
        numStats += 1.0
        # print "numCells: ", numCells
        if numCells in range(minOverlap, maxOverlap + 1):
          numCorrectSparsity += 1.0

          # Check KNN Classifier
          sdr = list(sdr)
          sdr.sort()
          dense = numpy.zeros(self.numTMCells)
          dense[sdr] = 1.0
          (winner, inferenceResult, dist, categoryDist) = \
            self.classifier.infer(dense)
          # print sdr, winner, stats['object'], winner == stats['object']
          # print categoryDist
          # print

          if winner == stats['object']:
            numCorrectClassifications += 1.0

    if numStats==0:
      return 0.0, 0.0

    return ((numCorrectSparsity / numStats),
            (numCorrectClassifications / numStats) )
For each object, decide whether the TM uniquely classified it by checking
    that the number of predictedActive cells are in an acceptable range.