Program: 32084
Project: 32084
Buggy source:
@SuppressWarnings("String_Node_Str") public void computeConfusionMatixForMultipleClassification(long records) throws IOException {
  PathFinder pathFinder=new PathFinder(modelConfig);
  SourceType sourceType=evalConfig.getDataSet().getSource();
  List<Scanner> scanners=ShifuFileUtils.getDataScanners(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  boolean isDir=ShifuFileUtils.isDir(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  int cnt=0;
  Set<String> posTags=new HashSet<String>(modelConfig.getPosTags(evalConfig));
  Set<String> negTags=new HashSet<String>(modelConfig.getNegTags(evalConfig));
  List<String> tags=getTags(modelConfig.getPosTags(evalConfig),modelConfig.getNegTags(evalConfig));
  int classes=tags.size();
  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");
      }
      String[] raw=scanner.nextLine().split("String_Node_Str");
      if (!isDir && cnt == 1) {
        continue;
      }
      String tag=raw[targetColumnIndex];
      if (StringUtils.isBlank(tag) || (!posTags.contains(tag) && !negTags.contains(tag))) {
        if (rd.nextDouble() < 0.01) {
          log.warn("String_Node_Str");
        }
        continue;
      }
      double[] scores=new double[classes];
      int maxIndex=-1;
      double maxScore=Double.NEGATIVE_INFINITY;
      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=tags.indexOf(tag);
      confusionMatrix[tagIndex][maxIndex]+=1L;
    }
    scanner.close();
  }
  Path localEvalMatrixFile=new Path(pathFinder.getEvalLocalMultiMatrixFile(evalConfig.getName()));
  log.info("String_Node_Str",localEvalMatrixFile);
  if (HDFSUtils.getLocalFS().exists(localEvalMatrixFile)) {
    HDFSUtils.getLocalFS().delete(localEvalMatrixFile);
  }
  BufferedWriter writer=null;
  try {
    writer=ShifuFileUtils.getWriter(localEvalMatrixFile.toString(),SourceType.LOCAL);
    writer.write("String_Node_Str" + StringUtils.join(tags,"String_Node_Str") + "String_Node_Str");
    for (int i=0; i < confusionMatrix.length; i++) {
      StringBuilder sb=new StringBuilder(300);
      sb.append(tags.get(i));
      for (int j=0; j < confusionMatrix[i].length; j++) {
        sb.append("String_Node_Str").append(confusionMatrix[i][j]);
      }
      sb.append("String_Node_Str");
      writer.write(tags.get(i) + "String_Node_Str" + sb.toString());
    }
  }
  finally {
    writer.close();
  }
  log.info("String_Node_Str");
  log.info("String_Node_Str",tags.toString());
  for (int i=0; i < confusionMatrix.length; i++) {
    log.info("String_Node_Str",tags.get(i),Arrays.toString(confusionMatrix[i]));
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void computeConfusionMatixForMultipleClassification(long records) throws IOException {
  PathFinder pathFinder=new PathFinder(modelConfig);
  SourceType sourceType=evalConfig.getDataSet().getSource();
  List<Scanner> scanners=ShifuFileUtils.getDataScanners(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  boolean isDir=ShifuFileUtils.isDir(pathFinder.getEvalScorePath(evalConfig,sourceType),sourceType);
  int cnt=0;
  Set<String> posTags=new HashSet<String>(modelConfig.getPosTags(evalConfig));
  Set<String> negTags=new HashSet<String>(modelConfig.getNegTags(evalConfig));
  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[][] 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");
      }
      String[] raw=scanner.nextLine().split("String_Node_Str");
      if (!isDir && cnt == 1) {
        continue;
      }
      String tag=raw[targetColumnIndex];
      if (modelConfig.isBinaryClassification()) {
        if (StringUtils.isBlank(tag) || (!posTags.contains(tag) && !negTags.contains(tag))) {
          if (rd.nextDouble() < 0.01) {
            log.warn("String_Node_Str");
          }
          continue;
        }
      }
 else {
        if (StringUtils.isBlank(tag) || !tagSet.contains(tag)) {
          if (rd.nextDouble() < 0.01) {
            log.warn("String_Node_Str");
          }
          continue;
        }
      }
      double[] scores=new double[classes];
      int maxIndex=-1;
      double maxScore=Double.NEGATIVE_INFINITY;
      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();
  }
  Path localEvalMatrixFile=new Path(pathFinder.getEvalLocalMultiMatrixFile(evalConfig.getName()));
  log.info("String_Node_Str",localEvalMatrixFile);
  if (HDFSUtils.getLocalFS().exists(localEvalMatrixFile)) {
    HDFSUtils.getLocalFS().delete(localEvalMatrixFile);
  }
  BufferedWriter writer=null;
  try {
    writer=ShifuFileUtils.getWriter(localEvalMatrixFile.toString(),SourceType.LOCAL);
    writer.write("String_Node_Str" + StringUtils.join(tags,"String_Node_Str") + "String_Node_Str");
    for (int i=0; i < confusionMatrix.length; i++) {
      StringBuilder sb=new StringBuilder(300);
      sb.append(tags.get(i));
      for (int j=0; j < confusionMatrix[i].length; j++) {
        sb.append("String_Node_Str").append(confusionMatrix[i][j]);
      }
      sb.append("String_Node_Str");
      writer.write(tags.get(i) + "String_Node_Str" + sb.toString());
    }
  }
  finally {
    writer.close();
  }
  log.info("String_Node_Str");
  log.info("String_Node_Str",tags.toString());
  for (int i=0; i < confusionMatrix.length; i++) {
    log.info("String_Node_Str",tags.get(i),Arrays.toString(confusionMatrix[i]));
  }
}