Program: 108019
Project: 108019
Buggy source:
/** 
 * Performs k-fold cross validation
 * @param handle
 * @param map
 * @param maps 
 * @param k
 * @param random
 * @param samplingFraction 
 * @return
 * @throws ParseException 
 */
private double getAccuracyAccordingToKFoldCrossValidation(DataHandleStatistics handle,Map<String,Integer> map,Map<String,Integer>[] maps,int k,Random random,double samplingFraction) throws ParseException {
  ConstantValueEncoder interceptEncoder=new ConstantValueEncoder("String_Node_Str");
  StaticWordValueEncoder featureEncoder=new StaticWordValueEncoder("String_Node_Str");
  List<Integer> rows=new ArrayList<>();
  for (int row=0; row < handle.getNumRows(); row++) {
    rows.add(row);
  }
  Collections.shuffle(rows,random);
  List<List<Integer>> folds=new ArrayList<>();
  int size=handle.getNumRows() / k;
  size=size > 1 ? size : 1;
  for (int i=0; i < k; i++) {
    checkInterrupt();
    int min=i * size;
    int max=(i + 1) * size;
    if (i == k - 1) {
      max=handle.getNumRows();
    }
    List<Integer> fold=new ArrayList<>();
    for (int j=min; j < max; j++) {
      if (random.nextDouble() <= samplingFraction) {
        fold.add(rows.get(j));
      }
    }
    folds.add(fold);
  }
  rows.clear();
  rows=null;
  double correct=0d;
  double total=0d;
  for (int i=0; i < folds.size(); i++) {
    Classifier classifier=new MultiClassLogisticRegression(indexes.length - 1,map.size());
    try {
      for (int j=0; j < folds.size(); j++) {
        if (j != i) {
          List<Integer> trainingset=folds.get(i);
          for (          int row : trainingset) {
            checkInterrupt();
            classifier.train(getFeatures(handle,row,maps,interceptEncoder,featureEncoder),getClass(handle,row,map));
          }
        }
      }
      List<Integer> validationset=folds.get(i);
      for (      int row : validationset) {
        checkInterrupt();
        total++;
        correct+=getClass(handle,row,map) == classifier.classify(getFeatures(handle,row,maps,interceptEncoder,featureEncoder)) ? 1 : 0;
      }
    }
 catch (    Exception e) {
      throw (e);
    }
 finally {
      classifier.close();
    }
  }
  return correct / total;
}

Fixed version (ground truth):
/** 
 * Performs k-fold cross validation
 * @param handle
 * @param map
 * @param maps 
 * @param k
 * @param random
 * @param samplingFraction 
 * @return
 * @throws ParseException 
 */
private double getAccuracyAccordingToKFoldCrossValidation(DataHandleStatistics handle,Map<String,Integer> map,Map<String,Integer>[] maps,int k,Random random,double samplingFraction) throws ParseException {
  ConstantValueEncoder interceptEncoder=new ConstantValueEncoder("String_Node_Str");
  StaticWordValueEncoder featureEncoder=new StaticWordValueEncoder("String_Node_Str");
  List<Integer> rows=new ArrayList<>();
  for (int row=0; row < handle.getNumRows(); row++) {
    rows.add(row);
  }
  Collections.shuffle(rows,random);
  List<List<Integer>> folds=new ArrayList<>();
  int size=handle.getNumRows() / k;
  size=size > 1 ? size : 1;
  for (int i=0; i < k; i++) {
    checkInterrupt();
    int min=i * size;
    int max=(i + 1) * size;
    if (i == k - 1) {
      max=handle.getNumRows();
    }
    List<Integer> fold=new ArrayList<>();
    for (int j=min; j < max; j++) {
      if (random.nextDouble() <= samplingFraction) {
        fold.add(rows.get(j));
      }
    }
    folds.add(fold);
  }
  rows.clear();
  rows=null;
  double correct=0d;
  double total=0d;
  for (int i=0; i < folds.size(); i++) {
    Classifier classifier=new MultiClassLogisticRegression(indexes.length - 1,map.size());
    try {
      for (int j=0; j < folds.size(); j++) {
        if (j != i) {
          for (          int row : folds.get(j)) {
            checkInterrupt();
            classifier.train(getFeatures(handle,row,maps,interceptEncoder,featureEncoder),getClass(handle,row,map));
          }
        }
      }
      for (      int row : folds.get(i)) {
        checkInterrupt();
        total++;
        correct+=getClass(handle,row,map) == classifier.classify(getFeatures(handle,row,maps,interceptEncoder,featureEncoder)) ? 1 : 0;
      }
    }
 catch (    Exception e) {
      throw (e);
    }
 finally {
      classifier.close();
    }
  }
  return correct / total;
}