Program: 31749
Project: 31749
Buggy source:
public void computeConfusionMatixForMultipleClassification(long records) throws IOException {
  SourceType sourceType=evalConfig.getDataSet().getSource();
  List<Scanner> scanners=ShifuFileUtils.getDataScanners(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  boolean isDir=ShifuFileUtils.isDir(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  Set<String> tagSet=new HashSet<String>(modelConfig.getFlattenTags(modelConfig.getPosTags(evalConfig),modelConfig.getNegTags(evalConfig)));
  List<Set<String>> tags=modelConfig.getSetTags(modelConfig.getPosTags(evalConfig),modelConfig.getNegTags(evalConfig));
  int classes=tags.size();
  long cnt=0, invalidTargetCnt=0;
  long[][] confusionMatrix=new long[classes][classes];
  for (  Scanner scanner : scanners) {
    while (scanner.hasNext()) {
      if ((++cnt) % 100000 == 0) {
        LOG.info("String_Node_Str" + cnt + "String_Node_Str");
      }
      if (!isDir && cnt == 1) {
        continue;
      }
      String[] raw=scanner.nextLine().split(Constants.DEFAULT_ESCAPE_DELIMITER);
      String tag=raw[targetColumnIndex];
      if (StringUtils.isBlank(tag) || !tagSet.contains(tag)) {
        invalidTargetCnt+=1;
        continue;
      }
      double[] scores=new double[classes];
      int maxIndex=-1;
      double maxScore=Double.NEGATIVE_INFINITY;
      if (CommonUtils.isDesicionTreeAlgorithm(modelConfig.getAlgorithm()) && !modelConfig.getTrain().isOneVsAll()) {
        double[] tagCounts=new double[tags.size()];
        for (int i=this.multiClassScore1Index; i < (raw.length - this.metaColumns); i++) {
          double dd=NumberFormatUtils.getDouble(raw[i],0d);
          tagCounts[(int)dd]+=1d;
        }
        double maxVotes=-1d;
        for (int i=0; i < tagCounts.length; i++) {
          if (tagCounts[i] > maxVotes) {
            maxIndex=i;
            maxScore=maxVotes=tagCounts[i];
          }
        }
      }
 else       if ((CommonUtils.isDesicionTreeAlgorithm(modelConfig.getAlgorithm()) || NNConstants.NN_ALG_NAME.equalsIgnoreCase(modelConfig.getAlgorithm())) && modelConfig.getTrain().isOneVsAll()) {
        for (int i=this.multiClassScore1Index; i < (classes + this.multiClassScore1Index); i++) {
          double dd=NumberFormatUtils.getDouble(raw[i],0d);
          if (dd > maxScore) {
            maxScore=dd;
            maxIndex=i - this.multiClassScore1Index;
          }
        }
      }
 else {
        for (int i=0; i < classes; i++) {
          for (int j=0; j < multiClassModelCnt; j++) {
            double dd=NumberFormatUtils.getDouble(raw[this.multiClassScore1Index + j * classes + i],0d);
            scores[i]+=dd;
          }
          scores[i]/=multiClassModelCnt;
          if (scores[i] > maxScore) {
            maxIndex=i;
            maxScore=scores[i];
          }
        }
      }
      int tagIndex=-1;
      for (int i=0; i < tags.size(); i++) {
        if (tags.get(i).contains(tag)) {
          tagIndex=i;
          break;
        }
      }
      confusionMatrix[tagIndex][maxIndex]+=1L;
    }
    scanner.close();
  }
  LOG.info("String_Node_Str",cnt,invalidTargetCnt,evalConfig.getName());
  writeToConfMatrixFile(tags,confusionMatrix);
  LOG.info("String_Node_Str");
  LOG.info(String.format("String_Node_Str","String_Node_Str",tags.toString()));
  for (int i=0; i < confusionMatrix.length; i++) {
    LOG.info(String.format("String_Node_Str",tags.get(i),Arrays.toString(confusionMatrix[i])));
  }
}

Fixed version (ground truth):
public void computeConfusionMatixForMultipleClassification(long records) throws IOException {
  SourceType sourceType=evalConfig.getDataSet().getSource();
  List<Scanner> scanners=ShifuFileUtils.getDataScanners(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  boolean isDir=ShifuFileUtils.isDir(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  Set<String> tagSet=new HashSet<String>(modelConfig.getFlattenTags(modelConfig.getPosTags(evalConfig),modelConfig.getNegTags(evalConfig)));
  List<Set<String>> tags=modelConfig.getSetTags(modelConfig.getPosTags(evalConfig),modelConfig.getNegTags(evalConfig));
  int classes=tags.size();
  long cnt=0, invalidTargetCnt=0;
  long[][] confusionMatrix=new long[classes][classes];
  for (  Scanner scanner : scanners) {
    while (scanner.hasNext()) {
      if ((++cnt) % 100000 == 0) {
        LOG.info("String_Node_Str" + cnt + "String_Node_Str");
      }
      if (!isDir && cnt == 1) {
        continue;
      }
      String[] raw=scanner.nextLine().split(Constants.DEFAULT_ESCAPE_DELIMITER);
      String tag=raw[targetColumnIndex];
      if (StringUtils.isBlank(tag) || !tagSet.contains(tag)) {
        invalidTargetCnt+=1;
        continue;
      }
      double[] scores=new double[classes];
      int maxIndex=-1;
      double maxScore=Double.NEGATIVE_INFINITY;
      if (CommonUtils.isTreeModel(modelConfig.getAlgorithm()) && !modelConfig.getTrain().isOneVsAll()) {
        double[] tagCounts=new double[tags.size()];
        for (int i=this.multiClassScore1Index; i < (raw.length - this.metaColumns); i++) {
          double dd=NumberFormatUtils.getDouble(raw[i],0d);
          tagCounts[(int)dd]+=1d;
        }
        double maxVotes=-1d;
        for (int i=0; i < tagCounts.length; i++) {
          if (tagCounts[i] > maxVotes) {
            maxIndex=i;
            maxScore=maxVotes=tagCounts[i];
          }
        }
      }
 else       if ((CommonUtils.isTreeModel(modelConfig.getAlgorithm()) || NNConstants.NN_ALG_NAME.equalsIgnoreCase(modelConfig.getAlgorithm())) && modelConfig.getTrain().isOneVsAll()) {
        for (int i=this.multiClassScore1Index; i < (classes + this.multiClassScore1Index); i++) {
          double dd=NumberFormatUtils.getDouble(raw[i],0d);
          if (dd > maxScore) {
            maxScore=dd;
            maxIndex=i - this.multiClassScore1Index;
          }
        }
      }
 else {
        for (int i=0; i < classes; i++) {
          for (int j=0; j < multiClassModelCnt; j++) {
            double dd=NumberFormatUtils.getDouble(raw[this.multiClassScore1Index + j * classes + i],0d);
            scores[i]+=dd;
          }
          scores[i]/=multiClassModelCnt;
          if (scores[i] > maxScore) {
            maxIndex=i;
            maxScore=scores[i];
          }
        }
      }
      int tagIndex=-1;
      for (int i=0; i < tags.size(); i++) {
        if (tags.get(i).contains(tag)) {
          tagIndex=i;
          break;
        }
      }
      confusionMatrix[tagIndex][maxIndex]+=1L;
    }
    scanner.close();
  }
  LOG.info("String_Node_Str",cnt,invalidTargetCnt,evalConfig.getName());
  writeToConfMatrixFile(tags,confusionMatrix);
  LOG.info("String_Node_Str");
  LOG.info(String.format("String_Node_Str","String_Node_Str",tags.toString()));
  for (int i=0; i < confusionMatrix.length; i++) {
    LOG.info(String.format("String_Node_Str",tags.get(i),Arrays.toString(confusionMatrix[i])));
  }
}