Program: 144107
Project: 144107
Buggy source:
public static void manyThresholdsExperiment(int errorEstimationMethod){
  String filename="String_Node_Str";
  String separator="String_Node_Str";
  double[] classificationThresholds=new double[]{0.01,0.02,0.03,0.04,0.05};
  double[] madMeans=new double[classificationThresholds.length];
  double madMean=0;
  for (int t=0; t < classificationThresholds.length; t++) {
    List<boolean[][]> functionOutputs=new ArrayList<>();
    List<boolean[]> trueLabels=new ArrayList<>();
    for (    File file : new File(filename).listFiles()) {
      if (file.isFile()) {
        DomainData data=parseLabeledDataFromCSVFile(file,separator,new double[]{classificationThresholds[t]});
        functionOutputs.add(data.functionOutputs);
        trueLabels.add(data.trueLabels);
      }
    }
    double[][] errorRates=new double[functionOutputs.size()][];
switch (errorEstimationMethod) {
case 0:
      for (int p=0; p < functionOutputs.size(); p++) {
        int numberOfFunctions=functionOutputs.get(p)[0].length;
        ErrorEstimationData errorEstimationData=new ErrorEstimationData.Builder(Arrays.asList(functionOutputs.get(p)),numberOfFunctions,true).build();
        ErrorEstimation errorEstimation=new ErrorEstimation.Builder(errorEstimationData).optimizationSolverType(ErrorEstimationInternalSolver.IP_OPT).build();
        double[] allErrorRates=errorEstimation.solve().getErrorRates().array;
        errorRates[p]=new double[numberOfFunctions];
        System.arraycopy(allErrorRates,0,errorRates[p],0,numberOfFunctions);
      }
    break;
case 1:
  ErrorEstimationSimpleGraphicalModel eesgm=new ErrorEstimationSimpleGraphicalModel(functionOutputs,1000);
eesgm.performGibbsSampling();
errorRates=eesgm.getErrorRatesMeans();
break;
case 2:
ErrorEstimationDomainsDPGraphicalModelComplicated eeddpgm=new ErrorEstimationDomainsDPGraphicalModelComplicated(functionOutputs,1000,null);
eeddpgm.performGibbsSampling();
errorRates=eeddpgm.getErrorRatesMeans();
}
double[] mad=new double[functionOutputs.size()];
for (int p=0; p < functionOutputs.size(); p++) {
double[] realErrorRates=new double[errorRates[p].length];
for (int i=0; i < trueLabels.get(p).length; i++) {
for (int j=0; j < errorRates[p].length; j++) realErrorRates[j]+=(functionOutputs.get(p)[i][j] != trueLabels.get(p)[i]) ? 1 : 0;
}
mad[p]=0;
for (int j=0; j < errorRates[p].length; j++) {
realErrorRates[j]/=trueLabels.get(p).length;
mad[p]+=Math.abs(errorRates[p][j] - realErrorRates[j]);
}
mad[p]/=errorRates[p].length;
madMeans[t]+=mad[p];
}
madMeans[t]/=functionOutputs.size();
madMean+=madMeans[t];
}
madMean/=madMeans.length;
System.out.println("String_Node_Str");
System.out.println("String_Node_Str" + madMean);
System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public static void manyThresholdsExperiment(int errorEstimationMethod){
  String filename="String_Node_Str";
  String separator="String_Node_Str";
  double[] classificationThresholds=new double[]{0.01,0.02,0.03,0.04,0.05};
  double[] madMeans=new double[classificationThresholds.length];
  double madMean=0;
  for (int t=0; t < classificationThresholds.length; t++) {
    List<boolean[][]> functionOutputs=new ArrayList<>();
    List<boolean[]> trueLabels=new ArrayList<>();
    for (    File file : new File(filename).listFiles()) {
      if (file.isFile()) {
        DomainData data=parseLabeledDataFromCSVFile(file,separator,new double[]{classificationThresholds[t]},1);
        functionOutputs.add(data.functionOutputs);
        trueLabels.add(data.trueLabels);
      }
    }
    double[][] errorRates=new double[functionOutputs.size()][];
switch (errorEstimationMethod) {
case 0:
      for (int p=0; p < functionOutputs.size(); p++) {
        int numberOfFunctions=functionOutputs.get(p)[0].length;
        ErrorEstimationData errorEstimationData=new ErrorEstimationData.Builder(Arrays.asList(functionOutputs.get(p)),numberOfFunctions,true).build();
        ErrorEstimation errorEstimation=new ErrorEstimation.Builder(errorEstimationData).optimizationSolverType(ErrorEstimationInternalSolver.IP_OPT).build();
        double[] allErrorRates=errorEstimation.solve().getErrorRates().array;
        errorRates[p]=new double[numberOfFunctions];
        System.arraycopy(allErrorRates,0,errorRates[p],0,numberOfFunctions);
      }
    break;
case 1:
  ErrorEstimationSimpleGraphicalModel eesgm=new ErrorEstimationSimpleGraphicalModel(functionOutputs,1000,10);
eesgm.performGibbsSampling();
errorRates=eesgm.getErrorRatesMeans();
break;
case 2:
ErrorEstimationDomainsDPGraphicalModelComplicated eeddpgm=new ErrorEstimationDomainsDPGraphicalModelComplicated(functionOutputs,1000,null);
eeddpgm.performGibbsSampling();
errorRates=eeddpgm.getErrorRatesMeans();
}
double[] mad=new double[functionOutputs.size()];
for (int p=0; p < functionOutputs.size(); p++) {
double[] realErrorRates=new double[errorRates[p].length];
for (int i=0; i < trueLabels.get(p).length; i++) {
for (int j=0; j < errorRates[p].length; j++) realErrorRates[j]+=(functionOutputs.get(p)[i][j] != trueLabels.get(p)[i]) ? 1 : 0;
}
mad[p]=0;
for (int j=0; j < errorRates[p].length; j++) {
realErrorRates[j]/=trueLabels.get(p).length;
mad[p]+=Math.abs(errorRates[p][j] - realErrorRates[j]);
}
mad[p]/=errorRates[p].length;
madMeans[t]+=mad[p];
}
madMeans[t]/=functionOutputs.size();
madMean+=madMeans[t];
}
madMean/=madMeans.length;
System.out.println("String_Node_Str");
System.out.println("String_Node_Str" + madMean);
System.out.println("String_Node_Str");
}