Program: 144110
Project: 144110
Buggy source:
public static Results runExperiment(ErrorEstimationMethod method,List<boolean[][]> functionOutputs,List<boolean[]> trueLabels,double alpha){
  double[][] errorRates=new double[functionOutputs.size()][];
  boolean[][] labels=new boolean[functionOutputs.size()][];
switch (method) {
case AR_2:
    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)),2,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);
      labels[p]=new boolean[functionOutputs.get(p).length];
      for (int i=0; i < functionOutputs.get(p).length; i++) {
        double labelsSum=0;
        double errorRatesSum=0;
        for (int j=0; j < functionOutputs.get(p)[i].length; j++) {
          labelsSum+=(1 - errorRates[p][j]) * (functionOutputs.get(p)[i][j] ? 1 : 0);
          errorRatesSum+=(1 - errorRates[p][j]);
        }
        labels[p][i]=labelsSum / errorRatesSum >= 0.5;
      }
    }
  break;
case AR_N:
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)),functionOutputs.get(0)[0].length,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);
  labels[p]=new boolean[functionOutputs.get(p).length];
  for (int i=0; i < functionOutputs.get(p).length; i++) {
    double labelsSum=0;
    double errorRatesSum=0;
    for (int j=0; j < functionOutputs.get(p)[i].length; j++) {
      labelsSum+=(1 - errorRates[p][j]) * (functionOutputs.get(p)[i][j] ? 1 : 0);
      errorRatesSum+=(1 - errorRates[p][j]);
    }
    labels[p][i]=labelsSum / errorRatesSum >= 0.5;
  }
}
break;
case SIMPLE_GM:
ErrorEstimationSimpleGraphicalModel eesgm=new ErrorEstimationSimpleGraphicalModel(functionOutputs,10000,10);
eesgm.performGibbsSampling();
errorRates=eesgm.getErrorRatesMeans();
double[][] labelMeansEesgm=eesgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEesgm[p][i] >= 0.5;
}
}
break;
case DOMAINS_DP_GM:
ErrorEstimationDomainsDPGraphicalModel eeddpgm=new ErrorEstimationDomainsDPGraphicalModel(functionOutputs,10000,10,alpha);
eeddpgm.performGibbsSampling();
errorRates=eeddpgm.getErrorRatesMeans();
double[][] labelMeansEeddpgm=eeddpgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEeddpgm[p][i] >= 0.5;
}
}
break;
case PAIRS_DP_GM:
ErrorEstimationDomainsDPMixedGraphicalModel eeddpmgm=new ErrorEstimationDomainsDPMixedGraphicalModel(functionOutputs,10000,10,alpha);
eeddpmgm.performGibbsSampling();
errorRates=eeddpmgm.getErrorRatesMeans();
double[][] labelMeansEeddpmgm=eeddpmgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEeddpmgm[p][i] >= 0.5;
}
}
break;
case DOMAINS_PER_CLASSIFIER_DP_GM:
ErrorEstimationDomainsDPFinalGraphicalModel eeddpfgm=new ErrorEstimationDomainsDPFinalGraphicalModel(functionOutputs,10000,10,alpha);
eeddpfgm.performGibbsSampling();
errorRates=eeddpfgm.getErrorRatesMeans();
double[][] labelMeansEeddpfgm=eeddpfgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEeddpfgm[p][i] >= 0.5;
}
}
break;
case COMPLICATED_DP_GM:
ErrorEstimationDomainsDPGraphicalModelComplicated eeddpgmc=new ErrorEstimationDomainsDPGraphicalModelComplicated(functionOutputs,1000,null);
eeddpgmc.performGibbsSampling();
errorRates=eeddpgmc.getErrorRatesMeans();
double[][] labelMeansEeddpgmc=eeddpgmc.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEeddpgmc[p][i] >= 0.5;
}
}
}
double[] errorRatesMAD=new double[functionOutputs.size()];
double errorRatesMADMean=0;
double[] labelsErrorRate=new double[functionOutputs.size()];
double labelsErrorRateMean=0;
for (int p=0; p < functionOutputs.size(); p++) {
labelsErrorRate[p]=0;
double[] realErrorRates=new double[errorRates[p].length];
for (int i=0; i < trueLabels.get(p).length; i++) {
labelsErrorRate[p]+=(labels[p][i] != trueLabels.get(p)[i]) ? 1 : 0;
for (int j=0; j < errorRates[p].length; j++) realErrorRates[j]+=(functionOutputs.get(p)[i][j] != trueLabels.get(p)[i]) ? 1 : 0;
}
labelsErrorRate[p]/=trueLabels.get(p).length;
labelsErrorRateMean+=labelsErrorRate[p];
errorRatesMAD[p]=0;
for (int j=0; j < errorRates[p].length; j++) {
realErrorRates[j]/=trueLabels.get(p).length;
errorRatesMAD[p]+=Math.abs(errorRates[p][j] - realErrorRates[j]);
}
errorRatesMAD[p]/=errorRates[p].length;
errorRatesMADMean+=errorRatesMAD[p];
}
errorRatesMADMean/=functionOutputs.size();
labelsErrorRateMean/=functionOutputs.size();
return new Results(errorRatesMADMean,labelsErrorRateMean);
}

Fixed version (ground truth):
public static Results runExperiment(ErrorEstimationMethod method,List<boolean[][]> functionOutputs,List<boolean[]> trueLabels,double alpha){
  double[][] errorRates=new double[functionOutputs.size()][];
  boolean[][] labels=new boolean[functionOutputs.size()][];
switch (method) {
case AR_2:
    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)),2,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);
      labels[p]=new boolean[functionOutputs.get(p).length];
      for (int i=0; i < functionOutputs.get(p).length; i++) {
        double labelsSum=0;
        double errorRatesSum=0;
        for (int j=0; j < functionOutputs.get(p)[i].length; j++) {
          labelsSum+=(1 - errorRates[p][j]) * (functionOutputs.get(p)[i][j] ? 1 : 0);
          errorRatesSum+=(1 - errorRates[p][j]);
        }
        labels[p][i]=labelsSum / errorRatesSum >= 0.5;
      }
    }
  break;
case AR_N:
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)),functionOutputs.get(0)[0].length,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);
  labels[p]=new boolean[functionOutputs.get(p).length];
  for (int i=0; i < functionOutputs.get(p).length; i++) {
    double labelsSum=0;
    double errorRatesSum=0;
    for (int j=0; j < functionOutputs.get(p)[i].length; j++) {
      labelsSum+=(1 - errorRates[p][j]) * (functionOutputs.get(p)[i][j] ? 1 : 0);
      errorRatesSum+=(1 - errorRates[p][j]);
    }
    labels[p][i]=labelsSum / errorRatesSum >= 0.5;
  }
}
break;
case SIMPLE_GM:
ErrorEstimationSimpleGraphicalModel eesgm=new ErrorEstimationSimpleGraphicalModel(functionOutputs,10000,10);
eesgm.performGibbsSampling();
errorRates=eesgm.getErrorRatesMeans();
double[][] labelMeansEesgm=eesgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEesgm[p][i] >= 0.5;
}
}
break;
case DOMAINS_DP_GM:
ErrorEstimationDomainsDPGraphicalModel eeddpgm=new ErrorEstimationDomainsDPGraphicalModel(functionOutputs,10000,10,alpha);
eeddpgm.performGibbsSampling();
errorRates=eeddpgm.getErrorRatesMeans();
double[][] labelMeansEeddpgm=eeddpgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEeddpgm[p][i] >= 0.5;
}
}
break;
case DOMAINS_FAST_DP_GM:
ErrorEstimationDomainsFastDPGraphicalModel eedfdpgm=new ErrorEstimationDomainsFastDPGraphicalModel(functionOutputs,10000,10,alpha);
eedfdpgm.performGibbsSampling();
errorRates=eedfdpgm.getErrorRatesMeans();
double[][] labelMeansEedfdpgm=eedfdpgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEedfdpgm[p][i] >= 0.5;
}
}
break;
case PAIRS_DP_GM:
ErrorEstimationDomainsDPMixedGraphicalModel eeddpmgm=new ErrorEstimationDomainsDPMixedGraphicalModel(functionOutputs,10000,10,alpha);
eeddpmgm.performGibbsSampling();
errorRates=eeddpmgm.getErrorRatesMeans();
double[][] labelMeansEeddpmgm=eeddpmgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEeddpmgm[p][i] >= 0.5;
}
}
break;
case PAIRS_FAST_DP_GM:
ErrorEstimationDomainsFastDPMixedGraphicalModel eedfdpmgm=new ErrorEstimationDomainsFastDPMixedGraphicalModel(functionOutputs,10000,10,alpha);
eedfdpmgm.performGibbsSampling();
errorRates=eedfdpmgm.getErrorRatesMeans();
double[][] labelMeansEedfdpmgm=eedfdpmgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEedfdpmgm[p][i] >= 0.5;
}
}
break;
case PAIRS_FAST_HDP_GM:
ErrorEstimationDomainsFastHDPMixedGraphicalModel eedfhdpmgm=new ErrorEstimationDomainsFastHDPMixedGraphicalModel(functionOutputs,10000,10,alpha);
eedfhdpmgm.performGibbsSampling();
errorRates=eedfhdpmgm.getErrorRatesMeans();
double[][] labelMeansEedfhdpmgm=eedfhdpmgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEedfhdpmgm[p][i] >= 0.5;
}
}
break;
case DOMAINS_PER_CLASSIFIER_DP_GM:
ErrorEstimationDomainsDPFinalGraphicalModel eeddpfgm=new ErrorEstimationDomainsDPFinalGraphicalModel(functionOutputs,10000,10,alpha);
eeddpfgm.performGibbsSampling();
errorRates=eeddpfgm.getErrorRatesMeans();
double[][] labelMeansEeddpfgm=eeddpfgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEeddpfgm[p][i] >= 0.5;
}
}
break;
case DOMAINS_PER_CLASSIFIER_FAST_DP_GM:
ErrorEstimationDomainsFastDPFinalGraphicalModel eedfdpfgm=new ErrorEstimationDomainsFastDPFinalGraphicalModel(functionOutputs,10000,10,alpha);
eedfdpfgm.performGibbsSampling();
errorRates=eedfdpfgm.getErrorRatesMeans();
double[][] labelMeansEedfdpfgm=eedfdpfgm.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEedfdpfgm[p][i] >= 0.5;
}
}
break;
case COMPLICATED_DP_GM:
ErrorEstimationDomainsDPGraphicalModelComplicated eeddpgmc=new ErrorEstimationDomainsDPGraphicalModelComplicated(functionOutputs,1000,null);
eeddpgmc.performGibbsSampling();
errorRates=eeddpgmc.getErrorRatesMeans();
double[][] labelMeansEeddpgmc=eeddpgmc.getLabelMeans();
for (int p=0; p < functionOutputs.size(); p++) {
labels[p]=new boolean[functionOutputs.get(p).length];
for (int i=0; i < functionOutputs.get(p).length; i++) {
labels[p][i]=labelMeansEeddpgmc[p][i] >= 0.5;
}
}
}
double[] errorRatesMAD=new double[functionOutputs.size()];
double errorRatesMADMean=0;
double[] labelsErrorRate=new double[functionOutputs.size()];
double labelsErrorRateMean=0;
for (int p=0; p < functionOutputs.size(); p++) {
labelsErrorRate[p]=0;
double[] realErrorRates=new double[errorRates[p].length];
for (int i=0; i < trueLabels.get(p).length; i++) {
labelsErrorRate[p]+=(labels[p][i] != trueLabels.get(p)[i]) ? 1 : 0;
for (int j=0; j < errorRates[p].length; j++) realErrorRates[j]+=(functionOutputs.get(p)[i][j] != trueLabels.get(p)[i]) ? 1 : 0;
}
labelsErrorRate[p]/=trueLabels.get(p).length;
labelsErrorRateMean+=labelsErrorRate[p];
errorRatesMAD[p]=0;
for (int j=0; j < errorRates[p].length; j++) {
realErrorRates[j]/=trueLabels.get(p).length;
errorRatesMAD[p]+=Math.abs(errorRates[p][j] - realErrorRates[j]);
}
errorRatesMAD[p]/=errorRates[p].length;
errorRatesMADMean+=errorRatesMAD[p];
}
errorRatesMADMean/=functionOutputs.size();
labelsErrorRateMean/=functionOutputs.size();
return new Results(errorRatesMADMean,labelsErrorRateMean);
}