def _handleSDRClassifierMultiStep(self, patternNZ,<EOL>inputTSRecordIdx,<EOL>rawInput):
inferenceArgs = self.getInferenceArgs()<EOL>predictedFieldName = inferenceArgs.get('<STR_LIT>', None)<EOL>if predictedFieldName is None:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>self._predictedFieldName = predictedFieldName<EOL>classifier = self._getClassifierRegion()<EOL>if not self._hasCL or classifier is None:<EOL><INDENT>return {}<EOL><DEDENT>sensor = self._getSensorRegion()<EOL>minLikelihoodThreshold = self._minLikelihoodThreshold<EOL>maxPredictionsPerStep = self._maxPredictionsPerStep<EOL>needLearning = self.isLearningEnabled()<EOL>inferences = {}<EOL>if self._classifierInputEncoder is None:<EOL><INDENT>if predictedFieldName is None:<EOL><INDENT>raise RuntimeError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>encoderList = sensor.getSelf().encoder.getEncoderList()<EOL>self._numFields = len(encoderList)<EOL>fieldNames = sensor.getSelf().encoder.getScalarNames()<EOL>if predictedFieldName in fieldNames:<EOL><INDENT>self._predictedFieldIdx = fieldNames.index(predictedFieldName)<EOL><DEDENT>else:<EOL><INDENT>self._predictedFieldIdx = None<EOL><DEDENT>if sensor.getSelf().disabledEncoder is not None:<EOL><INDENT>encoderList = sensor.getSelf().disabledEncoder.getEncoderList()<EOL><DEDENT>else:<EOL><INDENT>encoderList = []<EOL><DEDENT>if len(encoderList) >= <NUM_LIT:1>:<EOL><INDENT>fieldNames = sensor.getSelf().disabledEncoder.getScalarNames()<EOL>self._classifierInputEncoder = encoderList[fieldNames.index(<EOL>predictedFieldName)]<EOL><DEDENT>else:<EOL><INDENT>encoderList = sensor.getSelf().encoder.getEncoderList()<EOL>self._classifierInputEncoder = encoderList[self._predictedFieldIdx]<EOL><DEDENT><DEDENT>if not predictedFieldName in rawInput:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>% predictedFieldName)<EOL><DEDENT>absoluteValue = rawInput[predictedFieldName]<EOL>bucketIdx = self._classifierInputEncoder.getBucketIndices(absoluteValue)[<NUM_LIT:0>]<EOL>if isinstance(self._classifierInputEncoder, DeltaEncoder):<EOL><INDENT>if not hasattr(self,"<STR_LIT>"):<EOL><INDENT>self._ms_prevVal = absoluteValue<EOL><DEDENT>prevValue = self._ms_prevVal<EOL>self._ms_prevVal = absoluteValue<EOL>actualValue = absoluteValue - prevValue<EOL><DEDENT>else:<EOL><INDENT>actualValue = absoluteValue<EOL><DEDENT>if isinstance(actualValue, float) and math.isnan(actualValue):<EOL><INDENT>actualValue = SENTINEL_VALUE_FOR_MISSING_DATA<EOL><DEDENT>classifier.setParameter('<STR_LIT>', True)<EOL>classifier.setParameter('<STR_LIT>', needLearning)<EOL>classificationIn = {'<STR_LIT>': bucketIdx,<EOL>'<STR_LIT>': actualValue}<EOL>if inputTSRecordIdx is not None:<EOL><INDENT>recordNum = inputTSRecordIdx<EOL><DEDENT>else:<EOL><INDENT>recordNum = self.__numRunCalls<EOL><DEDENT>clResults = classifier.getSelf().customCompute(recordNum=recordNum,<EOL>patternNZ=patternNZ,<EOL>classification=classificationIn)<EOL>predictionSteps = classifier.getParameter('<STR_LIT>')<EOL>predictionSteps = [int(x) for x in predictionSteps.split('<STR_LIT:U+002C>')]<EOL>inferences[InferenceElement.multiStepPredictions] = dict()<EOL>inferences[InferenceElement.multiStepBestPredictions] = dict()<EOL>inferences[InferenceElement.multiStepBucketLikelihoods] = dict()<EOL>for steps in predictionSteps:<EOL><INDENT>likelihoodsVec = clResults[steps]<EOL>bucketValues = clResults['<STR_LIT>']<EOL>likelihoodsDict = dict()<EOL>bestActValue = None<EOL>bestProb = None<EOL>for (actValue, prob) in zip(bucketValues, likelihoodsVec):<EOL><INDENT>if actValue in likelihoodsDict:<EOL><INDENT>likelihoodsDict[actValue] += prob<EOL><DEDENT>else:<EOL><INDENT>likelihoodsDict[actValue] = prob<EOL><DEDENT>if bestProb is None or likelihoodsDict[actValue] > bestProb:<EOL><INDENT>bestProb = likelihoodsDict[actValue]<EOL>bestActValue = actValue<EOL><DEDENT><DEDENT>likelihoodsDict = HTMPredictionModel._removeUnlikelyPredictions(<EOL>likelihoodsDict, minLikelihoodThreshold, maxPredictionsPerStep)<EOL>bucketLikelihood = {}<EOL>for k in likelihoodsDict.keys():<EOL><INDENT>bucketLikelihood[self._classifierInputEncoder.getBucketIndices(k)[<NUM_LIT:0>]] = (<EOL>likelihoodsDict[k])<EOL><DEDENT>if isinstance(self._classifierInputEncoder, DeltaEncoder):<EOL><INDENT>if not hasattr(self, '<STR_LIT>'):<EOL><INDENT>self._ms_predHistories = dict()<EOL><DEDENT>predHistories = self._ms_predHistories<EOL>if not steps in predHistories:<EOL><INDENT>predHistories[steps] = deque()<EOL><DEDENT>predHistory = predHistories[steps]<EOL>sumDelta = sum(predHistory)<EOL>offsetDict = dict()<EOL>for (k, v) in likelihoodsDict.iteritems():<EOL><INDENT>if k is not None:<EOL><INDENT>offsetDict[absoluteValue+float(k)+sumDelta] = v<EOL><DEDENT><DEDENT>bucketLikelihoodOffset = {}<EOL>for k in offsetDict.keys():<EOL><INDENT>bucketLikelihoodOffset[self._classifierInputEncoder.getBucketIndices(k)[<NUM_LIT:0>]] = (<EOL>offsetDict[k])<EOL><DEDENT>if bestActValue is not None:<EOL><INDENT>predHistory.append(bestActValue)<EOL><DEDENT>if len(predHistory) >= steps:<EOL><INDENT>predHistory.popleft()<EOL><DEDENT>if len(offsetDict)><NUM_LIT:0>:<EOL><INDENT>inferences[InferenceElement.multiStepPredictions][steps] = offsetDict<EOL>inferences[InferenceElement.multiStepBucketLikelihoods][steps] = bucketLikelihoodOffset<EOL><DEDENT>else:<EOL><INDENT>inferences[InferenceElement.multiStepPredictions][steps] = likelihoodsDict<EOL>inferences[InferenceElement.multiStepBucketLikelihoods][steps] = bucketLikelihood<EOL><DEDENT>if bestActValue is None:<EOL><INDENT>inferences[InferenceElement.multiStepBestPredictions][steps] = None<EOL><DEDENT>else:<EOL><INDENT>inferences[InferenceElement.multiStepBestPredictions][steps] = (<EOL>absoluteValue + sumDelta + bestActValue)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>inferences[InferenceElement.multiStepPredictions][steps] = (<EOL>likelihoodsDict)<EOL>inferences[InferenceElement.multiStepBestPredictions][steps] = (<EOL>bestActValue)<EOL>inferences[InferenceElement.multiStepBucketLikelihoods][steps] = (<EOL>bucketLikelihood)<EOL><DEDENT><DEDENT>return inferences<EOL>
Handle the CLA Classifier compute logic when implementing multi-step
        prediction. This is where the patternNZ is associated with one of the
        other fields from the dataset 0 to N steps in the future. This method is
        used by each type of network (encoder only, SP only, SP +TM) to handle the
        compute logic through the CLA Classifier. It fills in the inference dict with
        the results of the compute.

        Parameters:
        -------------------------------------------------------------------
        patternNZ: The input to the CLA Classifier as a list of active input indices
        inputTSRecordIdx: The index of the record as computed from the timestamp
                      and aggregation interval. This normally increments by 1
                      each time unless there are missing records. If there is no
                      aggregation interval or timestamp in the data, this will be
                      None.
        rawInput:   The raw input to the sensor, as a dict.