def _updateStatsInferEnd(self, stats, bottomUpNZ, predictedState,<EOL>colConfidence):
<EOL>if not self.collectStats:<EOL><INDENT>return<EOL><DEDENT>stats['<STR_LIT>'] += <NUM_LIT:1><EOL>(numExtra2, numMissing2, confidences2) = self._checkPrediction(<EOL>patternNZs=[bottomUpNZ], output=predictedState,<EOL>colConfidence=colConfidence)<EOL>predictionScore, positivePredictionScore, negativePredictionScore = (<EOL>confidences2[<NUM_LIT:0>])<EOL>stats['<STR_LIT>'] = float(predictionScore)<EOL>stats['<STR_LIT>'] = <NUM_LIT:1.0> - float(positivePredictionScore)<EOL>stats['<STR_LIT>'] = float(negativePredictionScore)<EOL>stats['<STR_LIT>'] = numMissing2<EOL>stats['<STR_LIT>'] = numExtra2<EOL>if stats['<STR_LIT>'] <= self.burnIn:<EOL><INDENT>return<EOL><DEDENT>stats['<STR_LIT>'] += <NUM_LIT:1><EOL>numExpected = max(<NUM_LIT:1.0>, float(len(bottomUpNZ)))<EOL>stats['<STR_LIT>'] += numMissing2<EOL>stats['<STR_LIT>'] += numExtra2<EOL>stats['<STR_LIT>'] += <NUM_LIT> * numExtra2 / numExpected<EOL>stats['<STR_LIT>'] += <NUM_LIT> * numMissing2 / numExpected<EOL>stats['<STR_LIT>'] += float(predictionScore)<EOL>stats['<STR_LIT>'] += <NUM_LIT:1.0> - float(positivePredictionScore)<EOL>stats['<STR_LIT>'] += float(negativePredictionScore)<EOL>if self.collectSequenceStats:<EOL><INDENT>cc = self.cellConfidence['<STR_LIT>'] * self.infActiveState['<STR_LIT:t>']<EOL>sconf = cc.sum(axis=<NUM_LIT:1>)<EOL>for c in range(self.numberOfCols):<EOL><INDENT>if sconf[c] > <NUM_LIT:0>:<EOL><INDENT>cc[c, :] /= sconf[c]<EOL><DEDENT><DEDENT>self._internalStats['<STR_LIT>'] += cc<EOL><DEDENT>
Called at the end of learning and inference, this routine will update
a number of stats in our _internalStats dictionary, including our computed
prediction score.

:param stats            internal stats dictionary
:param bottomUpNZ       list of the active bottom-up inputs
:param predictedState   The columns we predicted on the last time step (should
                        match the current bottomUpNZ in the best case)
:param colConfidence    Column confidences we determined on the last time step