Source:
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater) { while (streamEventChunk.hasNext()) { StreamEvent event = streamEventChunk.next(); String[] featureValues = new String[attributeIndexMap.size()]; for (Map.Entry<Integer, int[]> entry : attributeIndexMap.entrySet()) { int featureIndex = entry.getKey(); int[] attributeIndexArray = entry.getValue(); Object dataValue = null; switch (attributeIndexArray[2]) { case 0 : dataValue = event.getBeforeWindowData()[attributeIndexArray[3]]; break; case 2 : dataValue = event.getOutputData()[attributeIndexArray[3]]; break; } featureValues[featureIndex] = String.valueOf(dataValue); } if (featureValues != null) { try { Object[] predictionResults = new Object[modelHandlers.length]; Object predictionResult = null; if (responseVariable != null) { if (algorithmClass.equals("classification")) { for (int i = 0; i < modelHandlers.length; i++) { predictionResults[i] = modelHandlers[i].predict(featureValues, outputType); } predictionResult = getMostFrequent(predictionResults); } else { double sum = 0; for (int i = 0; i < modelHandlers.length; i++) { sum += Double .parseDouble(modelHandlers[i].predict(featureValues, outputType).toString()); } predictionResult = sum / modelHandlers.length; } } else { throw new ExecutionPlanRuntimeException( "Error while predicting. " + "Response variable is null in models"); } Object[] output = new Object[] { predictionResult }; complexEventPopulater.populateComplexEvent(event, output); } catch (Exception e) { log.error("Error while predicting", e); throw new ExecutionPlanRuntimeException("Error while predicting", e); } } } nextProcessor.process(streamEventChunk); }

Target:
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater) { while (streamEventChunk.hasNext()) { StreamEvent event = streamEventChunk.next(); String[] featureValues = new String[attributeIndexMap.size()]; for (Map.Entry<Integer, int[]> entry : attributeIndexMap.entrySet()) { int featureIndex = entry.getKey(); int[] attributeIndexArray = entry.getValue(); Object dataValue = null; switch (attributeIndexArray[2]) { case 0 : dataValue = event.getBeforeWindowData()[attributeIndexArray[3]]; break; case 2 : dataValue = event.getOutputData()[attributeIndexArray[3]]; break; } featureValues[featureIndex] = String.valueOf(dataValue); } if (featureValues != null) { try { Object[] predictionResults = new Object[modelHandlers.length]; Object predictionResult = null; if (AlgorithmType.CLASSIFICATION.getValue().equals(algorithmClass)) { for (int i = 0; i < modelHandlers.length; i++) { predictionResults[i] = modelHandlers[i].predict(featureValues, outputType); } predictionResult = ObjectUtils.mode(predictionResults); } else if (AlgorithmType.NUMERICAL_PREDICTION.getValue().equals(algorithmClass)) { double sum = 0; for (int i = 0; i < modelHandlers.length; i++) { sum += Double.parseDouble(modelHandlers[i].predict(featureValues, outputType).toString()); } predictionResult = sum / modelHandlers.length; } else { String msg = String.format( "Error while predicting. Prediction is not supported for the algorithm class %s. ", algorithmClass); throw new ExecutionPlanRuntimeException(msg); } Object[] output = new Object[] { predictionResult }; complexEventPopulater.populateComplexEvent(event, output); } catch (Exception e) { log.error("Error while predicting", e); throw new ExecutionPlanRuntimeException("Error while predicting", e); } } } nextProcessor.process(streamEventChunk); }