nus-yam/ex-repair huggingface dataset:
Program: 32976
Project: 32976
Buggy source:
/** 
 * get the score of a given feature x and given label combination y_k.
 * @param vector
 * @param k
 * @return
 */
public double predictCombinationScore(Vector vector,int k){
  MultiLabel label=supportedCombinations.get(k);
  double score=0.0;
  for (int l=0; l < numClasses; l++) {
    if (label.matchClass(l)) {
      score+=this.weights.getWeightsWithoutBiasForClass(k).dot(vector);
      score+=this.weights.getBiasForClass(k);
    }
  }
  int start=this.weights.getNumWeightsForFeatures();
  for (int l1=0; l1 < numClasses; l1++) {
    for (int l2=l1 + 1; l2 < numClasses; l2++) {
      if (!label.matchClass(l1) && !label.matchClass(l2)) {
        score+=this.weights.getWeightForIndex(start);
      }
 else       if (label.matchClass(l1) && !label.matchClass(l2)) {
        score+=this.weights.getWeightForIndex(start + 1);
      }
 else       if (!label.matchClass(l1) && label.matchClass(l2)) {
        score+=this.weights.getWeightForIndex(start + 2);
      }
 else {
        score+=this.weights.getWeightForIndex(start + 3);
      }
      start+=4;
    }
  }
  return score;
}

Fixed version (ground truth):
/** 
 * get the score of a given feature x and given label combination y_k.
 * @param vector
 * @param k
 * @return
 */
public double predictCombinationScore(Vector vector,int k){
  return predictCombinationScore(vector,supportedCombinations.get(k));
}
Program: 32977
Project: 32977
Buggy source:
public void initCache(){
  int[] mapL1=new int[numWeightsForLabels];
  int[] mapL2=new int[numWeightsForLabels];
  int start=0;
  for (int l1=0; l1 < numClasses; l1++) {
    for (int l2=l1 + 1; l2 < numClasses; l2++) {
      mapL1[start]=l1;
      mapL1[start + 1]=l1;
      mapL1[start + 2]=l1;
      mapL1[start + 3]=l1;
      mapL2[start]=l2;
      mapL2[start + 1]=l2;
      mapL2[start + 2]=l2;
      mapL2[start + 3]=l2;
      start+=4;
    }
  }
  int[] mapClass=new int[numWeightsForFeatures];
  int[] mapFeature=new int[numWeightsForFeatures];
  for (int i=0; i < numWeightsForFeatures; i++) {
    mapClass[i]=cmlcrf.getWeights().getClassIndex(i);
    mapFeature[i]=cmlcrf.getWeights().getFeatureIndex(i);
  }
  cacheToL1=mapL1;
  cacheToL2=mapL2;
  cacheToClass=mapClass;
  cacheToFeature=mapFeature;
}

Fixed version (ground truth):
public void initCache(){
  int[] mapL1=new int[numWeightsForLabels];
  int[] mapL2=new int[numWeightsForLabels];
  int start=0;
  for (int l1=0; l1 < numClasses; l1++) {
    for (int l2=l1 + 1; l2 < numClasses; l2++) {
      mapL1[start]=l1;
      mapL1[start + 1]=l1;
      mapL1[start + 2]=l1;
      mapL1[start + 3]=l1;
      mapL2[start]=l2;
      mapL2[start + 1]=l2;
      mapL2[start + 2]=l2;
      mapL2[start + 3]=l2;
      start+=4;
    }
  }
  int[] mapClass=new int[numWeightsForFeatures];
  int[] mapFeature=new int[numWeightsForFeatures];
  for (int i=0; i < numWeightsForFeatures; i++) {
    mapClass[i]=cmlcrf.getWeights().getClassIndex(i);
    mapFeature[i]=cmlcrf.getWeights().getFeatureIndex(i);
  }
  parameterToL1=mapL1;
  parameterToL2=mapL2;
  parameterToClass=mapClass;
  parameterToFeature=mapFeature;
}
Program: 32979
Project: 32979
Buggy source:
/** 
 * create a subset with the indices it's fine to have duplicate indices idTranslator is not saved in sampleData as we may have duplicate extIds
 * @param dataSet
 * @param indices
 * @return
 */
public static MultiLabelClfDataSet sampleData(MultiLabelClfDataSet dataSet,List<Integer> indices){
  MultiLabelClfDataSet sample;
  sample=MLClfDataSetBuilder.getBuilder().numDataPoints(indices.size()).numFeatures(dataSet.getNumFeatures()).missingValue(dataSet.hasMissingValue()).dense(dataSet.isDense()).build();
  MultiLabel[] labels=dataSet.getMultiLabels();
  for (int i=0; i < indices.size(); i++) {
    int indexInOld=indices.get(i);
    Vector oldVector=dataSet.getRow(indexInOld);
    Set<Integer> label=labels[indexInOld].getMatchedLabels();
    sample.addLabels(i,label);
    for (    Vector.Element element : oldVector.nonZeroes()) {
      sample.setFeatureValue(i,element.index(),element.get());
    }
  }
  sample.setFeatureList(dataSet.getFeatureList());
  return sample;
}

Fixed version (ground truth):
/** 
 * create a subset with the indices it's fine to have duplicate indices idTranslator is not saved in sampleData as we may have duplicate extIds
 * @param dataSet
 * @param indices
 * @return
 */
public static MultiLabelClfDataSet sampleData(MultiLabelClfDataSet dataSet,List<Integer> indices){
  MultiLabelClfDataSet sample;
  sample=MLClfDataSetBuilder.getBuilder().numClasses(dataSet.getNumClasses()).numDataPoints(indices.size()).numFeatures(dataSet.getNumFeatures()).missingValue(dataSet.hasMissingValue()).dense(dataSet.isDense()).build();
  MultiLabel[] labels=dataSet.getMultiLabels();
  for (int i=0; i < indices.size(); i++) {
    int indexInOld=indices.get(i);
    Vector oldVector=dataSet.getRow(indexInOld);
    Set<Integer> label=labels[indexInOld].getMatchedLabels();
    sample.addLabels(i,label);
    for (    Vector.Element element : oldVector.nonZeroes()) {
      sample.setFeatureValue(i,element.index(),element.get());
    }
  }
  sample.setFeatureList(dataSet.getFeatureList());
  return sample;
}
Program: 32980
Project: 32980
Buggy source:
private void updateBinaryLogisticRegression(int k){
  IntStream intStream=IntStream.range(0,bmmClassifier.getNumClasses());
  if (isParallel) {
    intStream=intStream.parallel();
  }
  intStream.forEach(l -> {
    updateBinaryClassifier(k,l);
  }
);
}

Fixed version (ground truth):
private void updateBinaryLogisticRegression(int k){
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + k);
  }
  IntStream intStream=IntStream.range(0,bmmClassifier.getNumClasses());
  if (isParallel) {
    intStream=intStream.parallel();
  }
  intStream.forEach(l -> {
    updateBinaryClassifier(k,l);
  }
);
}
Program: 32981
Project: 32981
Buggy source:
/** 
 * only keep non-empty intervals, also adjust(extend) their boundaries
 * @param intervals
 * @return
 */
static List<Interval> compress(List<Interval> intervals){
  boolean inBlock=false;
  int start=0;
  int end=0;
  for (int i=0; i < intervals.size(); i++) {
    if (intervals.get(i).getProbabilisticCount() == 0) {
      if (!inBlock) {
        inBlock=true;
        start=i;
        end=i;
      }
 else {
        end=i;
      }
    }
 else {
      if (inBlock) {
        inBlock=false;
        double mid=(intervals.get(start).getLower() + intervals.get(end).getUpper()) / 2;
        intervals.get(start - 1).setUpper(mid);
        intervals.get(end + 1).setLower(mid);
      }
    }
  }
  List<Interval> compressed=new ArrayList<>(intervals.size());
  for (  Interval interval : intervals) {
    if (interval.getProbabilisticCount() != 0) {
      compressed.add(interval);
    }
  }
  return compressed;
}

Fixed version (ground truth):
/** 
 * only keep non-empty intervals, also adjust(extend) their boundaries
 * @param intervals
 * @return
 */
static List<Interval> compress(List<Interval> intervals){
  boolean inBlock=false;
  int start=0;
  int end=0;
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + intervals.size());
    logger.debug("String_Node_Str" + intervals);
    if (intervals.size() > 0) {
      logger.debug("String_Node_Str" + intervals.get(0));
    }
  }
  for (int i=0; i < intervals.size(); i++) {
    if (i > 1 && intervals.get(i).getProbabilisticCount() == 0) {
      if (!inBlock) {
        inBlock=true;
        start=i;
        end=i;
      }
 else {
        end=i;
      }
    }
 else {
      if (inBlock) {
        inBlock=false;
        double mid=(intervals.get(start).getLower() + intervals.get(end).getUpper()) / 2;
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str" + start);
        }
        intervals.get(start - 1).setUpper(mid);
        intervals.get(end + 1).setLower(mid);
      }
    }
  }
  List<Interval> compressed=new ArrayList<>(intervals.size());
  for (  Interval interval : intervals) {
    if (interval.getProbabilisticCount() != 0) {
      compressed.add(interval);
    }
  }
  return compressed;
}
Program: 32983
Project: 32983
Buggy source:
public static void main(String[] args) throws Exception {
  test3();
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  test4();
}
Program: 32984
Project: 32984
Buggy source:
private static double overlap(MultiLabel multiLabel1,MultiLabel multiLabel2){
  Set<Integer> set1=multiLabel1.getMatchedLabels();
  Set<Integer> set2=multiLabel2.getMatchedLabels();
  Set<Integer> union=new HashSet<>();
  union.addAll(set1);
  union.addAll(set2);
  Set<Integer> itersection=new HashSet<>();
  itersection.addAll(set1);
  itersection.retainAll(set2);
  return ((double)itersection.size()) / union.size();
}

Fixed version (ground truth):
private static double overlap(MultiLabel multiLabel1,MultiLabel multiLabel2){
  Set<Integer> set1=multiLabel1.getMatchedLabels();
  Set<Integer> set2=multiLabel2.getMatchedLabels();
  Set<Integer> union=new HashSet<>();
  union.addAll(set1);
  union.addAll(set2);
  Set<Integer> itersection=new HashSet<>();
  itersection.addAll(set1);
  itersection.retainAll(set2);
  if (union.size() == 0) {
    return 1;
  }
  return ((double)itersection.size()) / union.size();
}
Program: 32985
Project: 32985
Buggy source:
public BMMClassifier(int numClasses,int numClusters,int numFeatures){
  this.numLabels=numClasses;
  this.numClusters=numClusters;
  this.binaryLogitRegressions=new LogisticRegression[numClusters][numClasses];
  for (int k=0; k < numClusters; k++) {
    for (int l=0; l < numClasses; l++) {
      this.binaryLogitRegressions[k][l]=new LogisticRegression(2,numFeatures,true);
    }
  }
  this.softMaxRegression=new LogisticRegression(numClusters,numFeatures,true);
}

Fixed version (ground truth):
public BMMClassifier(int numClasses,int numClusters,int numFeatures){
  this.numLabels=numClasses;
  this.numClusters=numClusters;
  this.binaryLogitRegressions=new LogisticRegression[numClusters][numClasses];
  for (int k=0; k < numClusters; k++) {
    for (int l=0; l < numClasses; l++) {
      this.binaryLogitRegressions[k][l]=new LogisticRegression(2,numFeatures);
    }
  }
  this.softMaxRegression=new LogisticRegression(numClusters,numFeatures,true);
}
Program: 32986
Project: 32986
Buggy source:
private void updateBinaryLogisticRegressions(){
  IntStream.range(0,bmmClassifier.numClusters).parallel().forEach(this::updateBinaryLogisticRegression);
}

Fixed version (ground truth):
private void updateBinaryLogisticRegressions(){
  IntStream.range(0,bmmClassifier.numClusters).forEach(this::updateBinaryLogisticRegression);
}
Program: 32987
Project: 32987
Buggy source:
private void updateBinaryLogisticRegression(int k){
  LogisticRegression[] logisticRegressions=bmmClassifier.binaryLogitRegressions[k];
  for (int l=0; l < bmmClassifier.getNumClasses(); l++) {
    RidgeLogisticOptimizer ridgeLogisticOptimizer=new RidgeLogisticOptimizer(logisticRegressions[l],dataSet,gammasT[k],targetsDistributions[l],gaussianPriorforLogit);
  }
}

Fixed version (ground truth):
private void updateBinaryLogisticRegression(int k){
  LogisticRegression[] logisticRegressions=bmmClassifier.binaryLogitRegressions[k];
  for (int l=0; l < bmmClassifier.getNumClasses(); l++) {
    RidgeLogisticOptimizer ridgeLogisticOptimizer=new RidgeLogisticOptimizer(logisticRegressions[l],dataSet,gammasT[k],targetsDistributions[l],gaussianPriorforLogit);
    ridgeLogisticOptimizer.optimize();
  }
}
Program: 32988
Project: 32988
Buggy source:
private static void test2() throws Exception {
  ClfDataSet dataSet=TRECFormat.loadClfDataSet(new File("String_Node_Str","String_Node_Str"),DataSetType.CLF_SPARSE,true);
  ClfDataSet testSet=TRECFormat.loadClfDataSet(new File("String_Node_Str","String_Node_Str"),DataSetType.CLF_SPARSE,true);
  LogisticRegression logisticRegression=new LogisticRegression(dataSet.getNumClasses(),dataSet.getNumFeatures());
  double[] gammas=new double[dataSet.getNumDataPoints()];
  for (int n=0; n < dataSet.getNumDataPoints(); n++) {
    gammas[n]=1.0;
  }
  int[] labels=dataSet.getLabels();
  double[][] targets=new double[dataSet.getNumDataPoints()][2];
  for (int n=0; n < dataSet.getNumDataPoints(); n++) {
    int label=labels[n];
    if (label == 0.0) {
      targets[n][0]=1;
    }
 else {
      targets[n][1]=1;
    }
  }
  RidgeLogisticOptimizer optimizer=new RidgeLogisticOptimizer(logisticRegression,dataSet,gammas,targets,500);
  optimizer.getOptimizer().getTerminator().setMaxIteration(10000).setMode(Terminator.Mode.STANDARD);
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + Accuracy.accuracy(logisticRegression,dataSet));
  System.out.println("String_Node_Str" + Accuracy.accuracy(logisticRegression,testSet));
  optimizer.optimize();
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + Accuracy.accuracy(logisticRegression,dataSet));
  System.out.println("String_Node_Str" + Accuracy.accuracy(logisticRegression,testSet));
  System.out.println(optimizer.getOptimizer().getTerminator().getHistory());
}

Fixed version (ground truth):
private static void test2() throws Exception {
  ClfDataSet dataSet=TRECFormat.loadClfDataSet(new File(DATASETS,"String_Node_Str"),DataSetType.CLF_SPARSE,true);
  ClfDataSet testSet=TRECFormat.loadClfDataSet(new File(DATASETS,"String_Node_Str"),DataSetType.CLF_SPARSE,true);
  LogisticRegression logisticRegression=new LogisticRegression(dataSet.getNumClasses(),dataSet.getNumFeatures());
  double[] gammas=new double[dataSet.getNumDataPoints()];
  for (int n=0; n < dataSet.getNumDataPoints(); n++) {
    gammas[n]=1.0;
  }
  int[] labels=dataSet.getLabels();
  double[][] targets=new double[dataSet.getNumDataPoints()][2];
  for (int n=0; n < dataSet.getNumDataPoints(); n++) {
    int label=labels[n];
    if (label == 0.0) {
      targets[n][0]=1;
    }
 else {
      targets[n][1]=1;
    }
  }
  RidgeLogisticOptimizer optimizer=new RidgeLogisticOptimizer(logisticRegression,dataSet,gammas,targets,500);
  optimizer.getOptimizer().getTerminator().setMaxIteration(10000).setMode(Terminator.Mode.STANDARD);
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + Accuracy.accuracy(logisticRegression,dataSet));
  System.out.println("String_Node_Str" + Accuracy.accuracy(logisticRegression,testSet));
  optimizer.optimize();
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + Accuracy.accuracy(logisticRegression,dataSet));
  System.out.println("String_Node_Str" + Accuracy.accuracy(logisticRegression,testSet));
  System.out.println(optimizer.getOptimizer().getTerminator().getHistory());
}
Program: 32990
Project: 32990
Buggy source:
public BMMClassifier(int numClasses,int numClusters,int numFeatures){
  this.numLabels=numClasses;
  this.numClusters=numClusters;
  this.binaryLogitRegressions=new LogisticRegression[numClusters][numClasses];
  for (int k=0; k < numClusters; k++) {
    for (int l=0; l < numClasses; l++) {
      this.binaryLogitRegressions[k][l]=new LogisticRegression(2,numFeatures);
    }
  }
  this.softMaxRegression=new LogisticRegression(numClusters,numFeatures);
}

Fixed version (ground truth):
public BMMClassifier(int numClasses,int numClusters,int numFeatures){
  this.numLabels=numClasses;
  this.numClusters=numClusters;
  this.binaryLogitRegressions=new LogisticRegression[numClusters][numClasses];
  for (int k=0; k < numClusters; k++) {
    for (int l=0; l < numClasses; l++) {
      this.binaryLogitRegressions[k][l]=new LogisticRegression(2,numFeatures);
    }
  }
  this.softMaxRegression=new LogisticRegression(numClusters,numFeatures,true);
}
Program: 32991
Project: 32991
Buggy source:
private void updateGradient(){
  Vector weights=this.logisticRegression.getWeights().getAllWeights();
  this.gradient=this.predictedCounts.minus(empiricalCounts).plus(weights.divide(gaussianPriorVariance));
}

Fixed version (ground truth):
private void updateGradient(){
  Vector weightsVector=this.logisticRegression.getWeights().getAllWeights();
  Vector penalty=new DenseVector(weightsVector.size());
  for (int j=0; j < penalty.size(); j++) {
    int featureIndex=logisticRegression.getWeights().getFeatureIndex(j);
    if (featureIndex == -1) {
      penalty.set(j,0);
    }
 else {
      penalty.set(j,weightsVector.get(j) / gaussianPriorVariance);
    }
  }
  this.gradient=this.predictedCounts.minus(empiricalCounts).plus(penalty);
}
Program: 32992
Project: 32992
Buggy source:
public double getValue(){
  if (isValueCacheValid) {
    return this.value;
  }
  Vector parameters=getParameters();
  this.value=logisticRegression.dataSetKLWeightedDivergence(dataSet,targetDistributions,gammas) + parameters.dot(parameters) / (2 * gaussianPriorVariance);
  this.isValueCacheValid=true;
  return this.value;
}

Fixed version (ground truth):
public double getValue(){
  if (isValueCacheValid) {
    return this.value;
  }
  double weightSquare=0;
  for (int k=0; k < numClasses; k++) {
    Vector weightVector=logisticRegression.getWeights().getWeightsWithoutBiasForClass(k);
    weightSquare+=weightVector.dot(weightVector);
  }
  this.value=logisticRegression.dataSetKLWeightedDivergence(dataSet,targetDistributions,gammas) + weightSquare / (2 * gaussianPriorVariance);
  this.isValueCacheValid=true;
  return this.value;
}
Program: 32993
Project: 32993
Buggy source:
private void updateBernoulli(int k){
  double nk=0;
  for (int n=0; n < dataSet.getNumDataPoints(); n++) {
    nk+=gammas[n][k];
  }
  Vector average=new DenseVector(bmmClassifier.getNumClasses());
  for (int n=0; n < dataSet.getNumDataPoints(); n++) {
    average=average.plus(labels[n].times(gammas[n][k]));
  }
  average=average.divide(nk);
  for (int l=0; l < dataSet.getNumFeatures(); l++) {
    bmmClassifier.distributions[k][l]=new BinomialDistribution(1,average.get(l));
  }
}

Fixed version (ground truth):
private void updateBernoulli(int k){
  double nk=0;
  for (int n=0; n < dataSet.getNumDataPoints(); n++) {
    nk+=gammas[n][k];
  }
  Vector average=new DenseVector(bmmClassifier.getNumClasses());
  for (int n=0; n < dataSet.getNumDataPoints(); n++) {
    average=average.plus(labels[n].times(gammas[n][k]));
  }
  average=average.divide(nk);
  for (int l=0; l < bmmClassifier.numLabels; l++) {
    bmmClassifier.distributions[k][l]=new BinomialDistribution(1,average.get(l));
  }
}
Program: 32994
Project: 32994
Buggy source:
private void iterate(){
  eStep();
  mStep();
  this.terminator.add(getObjective());
}

Fixed version (ground truth):
public void iterate(){
  eStep();
  mStep();
  this.terminator.add(getObjective());
}
Program: 32995
Project: 32995
Buggy source:
@Override public MultiLabel predict(Vector vector){
  double maxProb=Double.MIN_VALUE;
  Vector predVector=new DenseVector(numLabels);
  for (int s=0; s < numSample; s++) {
    int[] clusters=IntStream.range(0,numClusters).toArray();
    double[] logisticProb=logisticRegression.predictClassProbs(vector);
    EnumeratedIntegerDistribution enumeratedIntegerDistribution=new EnumeratedIntegerDistribution(clusters,logisticProb);
    int cluster=enumeratedIntegerDistribution.sample();
    Vector candidateVector=new DenseVector(numLabels);
    for (int l=0; l < numLabels; l++) {
      candidateVector.set(l,distributions[cluster][l].sample());
    }
    double prob=0.0;
    double[] pYnk=clusterConditionalProbArr(candidateVector);
    for (int k=0; k < numClusters; k++) {
      prob+=logisticProb[k] * pYnk[k];
    }
    if (prob >= maxProb) {
      predVector=candidateVector;
    }
  }
  MultiLabel predLabel=new MultiLabel();
  for (int l=0; l < numLabels; l++) {
    if (predVector.get(l) == 1.0) {
      predLabel.addLabel(l);
    }
  }
  return predLabel;
}

Fixed version (ground truth):
@Override public MultiLabel predict(Vector vector){
  double maxProb=Double.NEGATIVE_INFINITY;
  Vector predVector=new DenseVector(numLabels);
  for (int s=0; s < numSample; s++) {
    int[] clusters=IntStream.range(0,numClusters).toArray();
    double[] logisticProb=logisticRegression.predictClassProbs(vector);
    EnumeratedIntegerDistribution enumeratedIntegerDistribution=new EnumeratedIntegerDistribution(clusters,logisticProb);
    int cluster=enumeratedIntegerDistribution.sample();
    Vector candidateVector=new DenseVector(numLabels);
    for (int l=0; l < numLabels; l++) {
      candidateVector.set(l,distributions[cluster][l].sample());
    }
    double prob=0.0;
    double[] pYnk=clusterConditionalProbArr(candidateVector);
    for (int k=0; k < numClusters; k++) {
      prob+=logisticProb[k] * pYnk[k];
    }
    if (prob >= maxProb) {
      predVector=candidateVector;
      maxProb=prob;
    }
  }
  MultiLabel predLabel=new MultiLabel();
  for (int l=0; l < numLabels; l++) {
    if (predVector.get(l) == 1.0) {
      predLabel.addLabel(l);
    }
  }
  return predLabel;
}
Program: 32996
Project: 32996
Buggy source:
private static void test1() throws Exception {
  MultiLabelClfDataSet dataSet=TRECFormat.loadMultiLabelClfDataSet(new File(DATASETS,"String_Node_Str"),DataSetType.ML_CLF_SPARSE,true);
  MultiLabelClfDataSet testSet=TRECFormat.loadMultiLabelClfDataSet(new File(DATASETS,"String_Node_Str"),DataSetType.ML_CLF_SPARSE,true);
  BMMClassifier bmmClassifier=new BMMClassifier(dataSet.getNumClasses(),2,dataSet.getNumFeatures());
  BMMOptimizer optimizer=new BMMOptimizer(bmmClassifier,dataSet,10000);
  bmmClassifier.setNumSample(1000);
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + Accuracy.accuracy(bmmClassifier,dataSet));
  System.out.println("String_Node_Str" + Accuracy.accuracy(bmmClassifier,testSet));
  for (int i=1; i <= 10; i++) {
    optimizer.iterate();
    System.out.println("String_Node_Str" + i);
    System.out.println("String_Node_Str" + Accuracy.accuracy(bmmClassifier,dataSet));
    System.out.println("String_Node_Str" + Overlap.overlap(bmmClassifier,dataSet));
    System.out.println("String_Node_Str" + Accuracy.accuracy(bmmClassifier,testSet));
    System.out.println("String_Node_Str" + Overlap.overlap(bmmClassifier,testSet));
  }
  System.out.println("String_Node_Str" + optimizer.getTerminator().getHistory());
  System.out.println(bmmClassifier);
}

Fixed version (ground truth):
private static void test1() throws Exception {
  MultiLabelClfDataSet dataSet=TRECFormat.loadMultiLabelClfDataSet(new File(DATASETS,"String_Node_Str"),DataSetType.ML_CLF_SPARSE,true);
  MultiLabelClfDataSet testSet=TRECFormat.loadMultiLabelClfDataSet(new File(DATASETS,"String_Node_Str"),DataSetType.ML_CLF_SPARSE,true);
  BMMClassifier bmmClassifier=new BMMClassifier(dataSet.getNumClasses(),2,dataSet.getNumFeatures());
  BMMOptimizer optimizer=new BMMOptimizer(bmmClassifier,dataSet,10000);
  bmmClassifier.setNumSample(100);
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + Accuracy.accuracy(bmmClassifier,dataSet));
  System.out.println("String_Node_Str" + Accuracy.accuracy(bmmClassifier,testSet));
  for (int i=1; i <= 10; i++) {
    optimizer.iterate();
    System.out.println("String_Node_Str" + i);
    System.out.println("String_Node_Str" + Accuracy.accuracy(bmmClassifier,dataSet));
    System.out.println("String_Node_Str" + Overlap.overlap(bmmClassifier,dataSet));
    System.out.println("String_Node_Str" + Accuracy.accuracy(bmmClassifier,testSet));
    System.out.println("String_Node_Str" + Overlap.overlap(bmmClassifier,testSet));
  }
  System.out.println("String_Node_Str" + optimizer.getTerminator().getHistory());
  System.out.println(bmmClassifier);
}
Program: 32997
Project: 32997
Buggy source:
/** 
 * Returns the precision.
 * @param tp true positives
 * @param fp false positives
 * @param fn false negatives
 * @return precision
 */
public static double precision(int tp,int fp,int fn){
  if (tp + fp + fn == 0) {
    return 1;
  }
  if (tp + fp == 0) {
    return 0;
  }
  return tp * 1.0 / (tp + fp);
}

Fixed version (ground truth):
/** 
 * Returns the precision.
 * @param tp true positives
 * @param fp false positives
 * @return precision
 */
public static double precision(int tp,int fp){
  if (tp + fp == 0) {
    return 1;
  }
  return tp * 1.0 / (tp + fp);
}
Program: 32998
Project: 32998
Buggy source:
/** 
 * Returns the recall.
 * @param tp true positives
 * @param fp false positives
 * @param fn false negatives
 * @return
 */
public static double recall(int tp,int fp,int fn){
  if (tp + fp + fn == 0) {
    return 1;
  }
  if (tp + fn == 0) {
    return 0;
  }
  return tp * 1.0 / (tp + fn);
}

Fixed version (ground truth):
/** 
 * Returns the recall.
 * @param tp true positives
 * @param fn false negatives
 * @return
 */
public static double recall(int tp,int fn){
  if (tp + fn == 0) {
    return 1;
  }
  return tp * 1.0 / (tp + fn);
}
Program: 32999
Project: 32999
Buggy source:
/** 
 * Returns the specificity.
 * @param tn true negaives
 * @param fp false positives
 * @param fn false negatives
 * @return the specificity.
 */
public static double specificity(int tn,int fp,int fn){
  if (tn + fp + fn == 0) {
    return 1;
  }
  if (tn + fp == 0) {
    return 0;
  }
  return tn * 1.0 / (tn + fp);
}

Fixed version (ground truth):
/** 
 * Returns the specificity.
 * @param tn true negaives
 * @param fp false positives
 * @return the specificity.
 */
public static double specificity(int tn,int fp){
  if (tn + fp == 0) {
    return 1;
  }
  return tn * 1.0 / (tn + fp);
}
Program: 33000
Project: 33000
Buggy source:
public double precision(int classIndex){
  return ConfusionMatrixMeasures.precision(truePositives[classIndex],falsePositives[classIndex],falseNegatives[classIndex]);
}

Fixed version (ground truth):
public double precision(int classIndex){
  return ConfusionMatrixMeasures.precision(truePositives[classIndex],falsePositives[classIndex]);
}
Program: 33001
Project: 33001
Buggy source:
public double recall(int classIndex){
  return ConfusionMatrixMeasures.recall(truePositives[classIndex],falsePositives[classIndex],falseNegatives[classIndex]);
}

Fixed version (ground truth):
public double recall(int classIndex){
  return ConfusionMatrixMeasures.recall(truePositives[classIndex],falseNegatives[classIndex]);
}
Program: 33002
Project: 33002
Buggy source:
public double f1(int classIndex){
  return ConfusionMatrixMeasures.f1Score(truePositives[classIndex],falsePositives[classIndex],falseNegatives[classIndex]);
}

Fixed version (ground truth):
public double f1(int classIndex){
  double precision=precision(classIndex);
  double recall=recall(classIndex);
  return FMeasure.f1(precision,recall);
}
Program: 33003
Project: 33003
Buggy source:
private static double getPrecision(Set<Integer> label,Set<Integer> positivePredict){
  int tp=0;
  int fp=0;
  int fn=0;
  for (  Integer predict : positivePredict) {
    if (label.contains(predict)) {
      tp++;
    }
  }
  fp=positivePredict.size() - tp;
  fn=label.size() - tp;
  return ConfusionMatrixMeasures.precision(tp,fp,fn);
}

Fixed version (ground truth):
private static double getPrecision(Set<Integer> label,Set<Integer> positivePredict){
  int tp=0;
  int fp=0;
  int fn=0;
  for (  Integer predict : positivePredict) {
    if (label.contains(predict)) {
      tp++;
    }
  }
  fp=positivePredict.size() - tp;
  fn=label.size() - tp;
  return ConfusionMatrixMeasures.precision(tp,fp);
}
Program: 33004
Project: 33004
Buggy source:
/** 
 * Returns the Macro F score by given label index.
 * @param beta
 * @param labelIndex
 * @return F score of given label index
 */
public double getFScore(double beta,int labelIndex){
  return ConfusionMatrixMeasures.fScore(truePositives[labelIndex],falsePositives[labelIndex],falseNegatives[labelIndex],beta);
}

Fixed version (ground truth):
/** 
 * Returns the Macro F score by given label index.
 * @param beta
 * @param labelIndex
 * @return F score of given label index
 */
public double getFScore(double beta,int labelIndex){
  double precision=getPrecision(labelIndex);
  double recall=getRecall(labelIndex);
  return FMeasure.fBeta(precision,recall,beta);
}
Program: 33005
Project: 33005
Buggy source:
/** 
 * Returns the Macro recall by given label index.
 * @param labelIndex
 * @return recall of given label index
 */
public double getRecall(int labelIndex){
  return ConfusionMatrixMeasures.recall(truePositives[labelIndex],falsePositives[labelIndex],falseNegatives[labelIndex]);
}

Fixed version (ground truth):
/** 
 * Returns the Macro recall by given label index.
 * @param labelIndex
 * @return recall of given label index
 */
public double getRecall(int labelIndex){
  return ConfusionMatrixMeasures.recall(truePositives[labelIndex],falseNegatives[labelIndex]);
}
Program: 33006
Project: 33006
Buggy source:
/** 
 * Returns the Macro specificity by given label index.
 * @param labelIndex
 * @return specificity of given label index
 */
public double getSpecificity(int labelIndex){
  return ConfusionMatrixMeasures.specificity(trueNegatives[labelIndex],falsePositives[labelIndex],falseNegatives[labelIndex]);
}

Fixed version (ground truth):
/** 
 * Returns the Macro specificity by given label index.
 * @param labelIndex
 * @return specificity of given label index
 */
public double getSpecificity(int labelIndex){
  return ConfusionMatrixMeasures.specificity(trueNegatives[labelIndex],falsePositives[labelIndex]);
}
Program: 33007
Project: 33007
Buggy source:
/** 
 * Returns the Macro precision by given label index.
 * @param labelIndex
 * @return precision of given label index
 */
public double getPrecision(int labelIndex){
  return ConfusionMatrixMeasures.precision(truePositives[labelIndex],falsePositives[labelIndex],falseNegatives[labelIndex]);
}

Fixed version (ground truth):
/** 
 * Returns the Macro precision by given label index.
 * @param labelIndex
 * @return precision of given label index
 */
public double getPrecision(int labelIndex){
  return ConfusionMatrixMeasures.precision(truePositives[labelIndex],falsePositives[labelIndex]);
}
Program: 33008
Project: 33008
Buggy source:
/** 
 * Returns the average Micro recall for all labels.
 * @return average recall
 */
public double getRecall(){
  int tp=IntStream.of(truePositives).sum();
  int fp=IntStream.of(falsePositives).sum();
  int fn=IntStream.of(falseNegatives).sum();
  return ConfusionMatrixMeasures.recall(tp,fp,fn);
}

Fixed version (ground truth):
/** 
 * Returns the average Micro recall for all labels.
 * @return average recall
 */
public double getRecall(){
  int tp=IntStream.of(truePositives).sum();
  int fn=IntStream.of(falseNegatives).sum();
  return ConfusionMatrixMeasures.recall(tp,fn);
}
Program: 33009
Project: 33009
Buggy source:
/** 
 * Returns the average Micro specificity for all labels.
 * @return average specificity
 */
public double getSpecificity(){
  int tn=IntStream.of(trueNegatives).sum();
  int fp=IntStream.of(falsePositives).sum();
  int fn=IntStream.of(falseNegatives).sum();
  return ConfusionMatrixMeasures.specificity(tn,fp,fn);
}

Fixed version (ground truth):
/** 
 * Returns the average Micro specificity for all labels.
 * @return average specificity
 */
public double getSpecificity(){
  int tn=IntStream.of(trueNegatives).sum();
  int fp=IntStream.of(falsePositives).sum();
  return ConfusionMatrixMeasures.specificity(tn,fp);
}
Program: 33010
Project: 33010
Buggy source:
/** 
 * Returns the average Micro precision for all labels.
 * @return average precision
 */
public double getPrecision(){
  int tp=IntStream.of(truePositives).sum();
  int fp=IntStream.of(falsePositives).sum();
  int fn=IntStream.of(falseNegatives).sum();
  return ConfusionMatrixMeasures.precision(tp,fp,fn);
}

Fixed version (ground truth):
/** 
 * Returns the average Micro precision for all labels.
 * @return average precision
 */
public double getPrecision(){
  int tp=IntStream.of(truePositives).sum();
  int fp=IntStream.of(falsePositives).sum();
  return ConfusionMatrixMeasures.precision(tp,fp);
}
Program: 33013
Project: 33013
Buggy source:
/** 
 * use as an inverted index no score is computed
 * @param term stemmed term
 * @return
 * @throws Exception
 */
public List<String> termFilter(String field,String term) throws Exception {
  StopWatch stopWatch=null;
  if (logger.isDebugEnabled()) {
    stopWatch=new StopWatch();
    stopWatch.start();
  }
  TermFilterBuilder termFilterBuilder=new TermFilterBuilder(field,term);
  SearchResponse response=client.prepareSearch(indexName).setSize(this.numDocs).setHighlighterFilter(false).setTrackScores(false).setNoFields().setExplain(false).setFetchSource(false).setQuery(QueryBuilders.constantScoreQuery(termFilterBuilder)).execute().actionGet();
  List<String> list=new ArrayList<>(response.getHits().getHits().length);
  for (  SearchHit searchHit : response.getHits()) {
    list.add(searchHit.getId());
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + term + "String_Node_Str"+ stopWatch+ "String_Node_Str"+ list.size()+ "String_Node_Str");
  }
  return list;
}

Fixed version (ground truth):
/** 
 * use as an inverted index no score is computed
 * @param term stemmed term
 * @return
 * @throws Exception
 */
public List<String> termFilter(String field,String term,String[] ids) throws Exception {
  StopWatch stopWatch=null;
  if (logger.isDebugEnabled()) {
    stopWatch=new StopWatch();
    stopWatch.start();
  }
  TermFilterBuilder termFilterBuilder=new TermFilterBuilder(field,term);
  IdsFilterBuilder idsFilterBuilder=new IdsFilterBuilder(documentType);
  idsFilterBuilder.addIds(ids);
  SearchResponse response=client.prepareSearch(indexName).setSize(ids.length).setHighlighterFilter(false).setTrackScores(false).setNoFields().setExplain(false).setFetchSource(false).setQuery(QueryBuilders.constantScoreQuery(FilterBuilders.andFilter(termFilterBuilder,idsFilterBuilder))).execute().actionGet();
  List<String> list=new ArrayList<>(response.getHits().getHits().length);
  for (  SearchHit searchHit : response.getHits()) {
    list.add(searchHit.getId());
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + term + "String_Node_Str"+ stopWatch+ "String_Node_Str"+ list.size()+ "String_Node_Str");
  }
  return list;
}
Program: 33014
Project: 33014
Buggy source:
public static void loadFeatures(ESIndex index,DataSet dataSet,FeatureList features,IdTranslator idTranslator){
  boolean[] toHandle=new boolean[features.size()];
  Arrays.fill(toHandle,true);
  for (int i=0; i < features.size(); i++) {
    Feature feature=features.get(i);
    if (toHandle[i]) {
      if (feature instanceof CategoricalFeature) {
        int numCategories=((CategoricalFeature)feature).getNumCategories();
        for (int pos=i + 1; pos < i + numCategories; pos++) {
          toHandle[pos]=false;
        }
      }
    }
  }
  IntStream.range(0,features.size()).parallel().filter(i -> toHandle[i]).forEach(i -> {
    Feature feature=features.get(i);
    if (feature instanceof CategoricalFeature) {
      loadCategoricalFeature(index,dataSet,(CategoricalFeature)feature,idTranslator);
    }
 else     if (feature instanceof Ngram) {
      loadNgramFeature(index,dataSet,(Ngram)feature,idTranslator);
    }
 else     if (feature instanceof SpanNotNgram) {
      loadSpanNotNgramFeature(index,dataSet,(SpanNotNgram)feature,idTranslator);
    }
 else {
      loadNumericalFeature(index,dataSet,feature,idTranslator);
    }
  }
);
}

Fixed version (ground truth):
public static void loadFeatures(ESIndex index,DataSet dataSet,FeatureList features,IdTranslator idTranslator){
  IntStream.range(0,features.size()).parallel().forEach(i -> {
    Feature feature=features.get(i);
    if (feature instanceof CategoricalFeature) {
      loadCategoricalFeature(index,dataSet,(CategoricalFeature)feature,idTranslator);
    }
 else     if (feature instanceof Ngram) {
      loadNgramFeature(index,dataSet,(Ngram)feature,idTranslator);
    }
 else     if (feature instanceof SpanNotNgram) {
      loadSpanNotNgramFeature(index,dataSet,(SpanNotNgram)feature,idTranslator);
    }
 else {
      loadNumericalFeature(index,dataSet,feature,idTranslator);
    }
  }
);
}
Program: 33015
Project: 33015
Buggy source:
public static void loadCategoricalFeature(ESIndex index,DataSet dataSet,CategoricalFeature feature,IdTranslator idTranslator){
  String[] dataIndexIds=idTranslator.getAllExtIds();
  String variableName=feature.getVariableName();
  Map<String,Integer> categoryIndexMap=feature.getCategoryIndexMap();
  String source=feature.getSettings().get("String_Node_Str");
  if (source.equals("String_Node_Str")) {
    Arrays.stream(dataIndexIds).forEach(id -> {
      int algorithmId=idTranslator.toIntId(id);
      String category=index.getStringField(id,variableName);
      if (categoryIndexMap.containsKey(category)) {
        int featureIndex=categoryIndexMap.get(category);
        dataSet.setFeatureValue(algorithmId,featureIndex,1);
      }
    }
);
  }
}

Fixed version (ground truth):
public static void loadCategoricalFeature(ESIndex index,DataSet dataSet,CategoricalFeature feature,IdTranslator idTranslator){
  String[] dataIndexIds=idTranslator.getAllExtIds();
  String variableName=feature.getVariableName();
  int featureIndex=feature.getIndex();
  List<String> matchedIds=null;
  try {
    matchedIds=index.termFilter(variableName,feature.getCategory(),dataIndexIds);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  for (  String matchedId : matchedIds) {
    int algorithmId=idTranslator.toIntId(matchedId);
    dataSet.setFeatureValue(algorithmId,featureIndex,1);
  }
}
Program: 33016
Project: 33016
Buggy source:
public void optimize(){
  LinkedList<Double> valueQueue=new LinkedList<>();
  valueQueue.add(function.getValue());
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + valueQueue.getLast());
  }
  int iteration=0;
  iterate();
  iteration+=1;
  valueQueue.add(function.getValue());
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + iteration);
    logger.debug("String_Node_Str" + valueQueue.getLast());
  }
  int convergenceTraceCounter=0;
  while (true) {
    if (checkConvergence) {
      if (Math.abs(valueQueue.getFirst() - valueQueue.getLast()) < epsilon * valueQueue.getFirst()) {
        convergenceTraceCounter+=1;
      }
 else {
        convergenceTraceCounter=0;
      }
      if (convergenceTraceCounter == 5) {
        terminate=true;
      }
    }
    if (iteration == maxIteration) {
      terminate=true;
    }
    if (terminate) {
      break;
    }
    iterate();
    iteration+=1;
    valueQueue.remove();
    valueQueue.add(function.getValue());
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + iteration);
      logger.debug("String_Node_Str" + valueQueue.getLast());
    }
  }
}

Fixed version (ground truth):
public void optimize(){
  LinkedList<Double> valueQueue=new LinkedList<>();
  valueQueue.add(function.getValue());
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + valueQueue.getLast());
  }
  int iteration=0;
  iterate();
  iteration+=1;
  valueQueue.add(function.getValue());
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + iteration);
    logger.debug("String_Node_Str" + valueQueue.getLast());
  }
  int convergenceTraceCounter=0;
  while (true) {
    if (checkConvergence) {
      logger.debug("String_Node_Str" + Math.abs(valueQueue.getFirst() - valueQueue.getLast()));
      if (Math.abs(valueQueue.getFirst() - valueQueue.getLast()) <= Math.abs(epsilon * valueQueue.getFirst())) {
        convergenceTraceCounter+=1;
      }
 else {
        convergenceTraceCounter=0;
      }
      if (convergenceTraceCounter == 5) {
        terminate=true;
      }
      logger.debug("String_Node_Str" + convergenceTraceCounter);
    }
    if (iteration == maxIteration) {
      terminate=true;
    }
    if (terminate) {
      break;
    }
    iterate();
    iteration+=1;
    valueQueue.remove();
    valueQueue.add(function.getValue());
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + iteration);
      logger.debug("String_Node_Str" + valueQueue.getLast());
    }
  }
}
Program: 33017
Project: 33017
Buggy source:
public void optimize(){
  if (maxIteration == 0) {
    return;
  }
  LinkedList<Double> valueQueue=new LinkedList<>();
  valueQueue.add(function.getValue());
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + valueQueue.getLast());
  }
  int iteration=0;
  iterate();
  iteration+=1;
  valueQueue.add(function.getValue());
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + iteration);
    logger.debug("String_Node_Str" + valueQueue.getLast());
  }
  int convergenceTraceCounter=0;
  while (true) {
    if (checkConvergence) {
      if (Math.abs(valueQueue.getFirst() - valueQueue.getLast()) < epsilon * valueQueue.getFirst()) {
        convergenceTraceCounter+=1;
      }
 else {
        convergenceTraceCounter=0;
      }
      if (convergenceTraceCounter == 5) {
        terminate=true;
      }
    }
    if (iteration == maxIteration) {
      terminate=true;
    }
    if (terminate) {
      break;
    }
    iterate();
    iteration+=1;
    valueQueue.remove();
    valueQueue.add(function.getValue());
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + iteration);
      logger.debug("String_Node_Str" + valueQueue.getLast());
    }
  }
}

Fixed version (ground truth):
public void optimize(){
  if (maxIteration == 0) {
    return;
  }
  LinkedList<Double> valueQueue=new LinkedList<>();
  valueQueue.add(function.getValue());
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + valueQueue.getLast());
  }
  int iteration=0;
  iterate();
  iteration+=1;
  valueQueue.add(function.getValue());
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + iteration);
    logger.debug("String_Node_Str" + valueQueue.getLast());
  }
  int convergenceTraceCounter=0;
  while (true) {
    if (checkConvergence) {
      logger.debug("String_Node_Str" + Math.abs(valueQueue.getFirst() - valueQueue.getLast()));
      if (Math.abs(valueQueue.getFirst() - valueQueue.getLast()) <= Math.abs(epsilon * valueQueue.getFirst())) {
        convergenceTraceCounter+=1;
      }
 else {
        convergenceTraceCounter=0;
      }
      if (convergenceTraceCounter == 5) {
        terminate=true;
      }
      logger.debug("String_Node_Str" + convergenceTraceCounter);
    }
    if (iteration == maxIteration) {
      terminate=true;
    }
    if (terminate) {
      break;
    }
    iterate();
    iteration+=1;
    valueQueue.remove();
    valueQueue.add(function.getValue());
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + iteration);
      logger.debug("String_Node_Str" + valueQueue.getLast());
    }
  }
}
Program: 33018
Project: 33018
Buggy source:
private Regressor fitRegressor(){
  return lsbConfig.getRegressorFactory().fit(dataSet);
}

Fixed version (ground truth):
private Regressor fitRegressor(){
  return lsbConfig.getRegressorFactory().fit(dataSet,gradients);
}
Program: 33021
Project: 33021
Buggy source:
@Override public void setParameters(Vector parameters){
  this.vector=parameters;
}

Fixed version (ground truth):
@Override public void setParameters(Vector parameters){
  this.vector=parameters;
  this.isValueCacheValid=false;
  this.isGradientCacheValid=false;
}
Program: 33022
Project: 33022
Buggy source:
@Override public void setParameters(Vector parameters){
  this.vector=parameters;
}

Fixed version (ground truth):
@Override public void setParameters(Vector parameters){
  this.vector=parameters;
  this.isValueCacheValid=false;
  this.isGradientCacheValid=false;
}
Program: 33023
Project: 33023
Buggy source:
@Override public void serialize(Feature feature,JsonGenerator jsonGenerator,SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
  jsonGenerator.writeStartObject();
  jsonGenerator.writeNumberField("String_Node_Str",feature.getIndex());
  jsonGenerator.writeStringField("String_Node_Str",feature.name);
  jsonGenerator.writeEndObject();
}

Fixed version (ground truth):
@Override public void serialize(Feature feature,JsonGenerator jsonGenerator,SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
  jsonGenerator.writeStartObject();
  if (feature.isIndexAssigned()) {
    jsonGenerator.writeNumberField("String_Node_Str",feature.getIndex());
  }
  jsonGenerator.writeStringField("String_Node_Str",feature.name);
  jsonGenerator.writeEndObject();
}
Program: 33025
Project: 33025
Buggy source:
private boolean valid(){
  if (numDataPoints <= 0) {
    return false;
  }
  if (numFeatures <= 0) {
    return false;
  }
  if (numClasses <= 0) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
private boolean valid(){
  if (numDataPoints <= 0) {
    System.out.println("String_Node_Str");
    return false;
  }
  if (numFeatures <= 0) {
    System.out.println("String_Node_Str");
    return false;
  }
  if (numClasses <= 0) {
    System.out.println("String_Node_Str");
    return false;
  }
  return true;
}
Program: 33030
Project: 33030
Buggy source:
public static void loadFeatures(ESIndex index,DataSet dataSet,FeatureList features,IdTranslator idTranslator){
  boolean[] toHandle=new boolean[features.size()];
  Arrays.fill(toHandle,true);
  for (int i=0; i < features.size(); i++) {
    Feature feature=features.get(i);
    if (toHandle[i]) {
      if (feature instanceof CategoricalFeature) {
        int numCategories=((CategoricalFeature)feature).getNumCategories();
        for (int pos=i + 1; pos < i + numCategories; pos++) {
          toHandle[pos]=false;
        }
      }
    }
  }
  IntStream.range(0,features.size()).parallel().filter(i -> toHandle[i]).forEach(i -> {
    Feature feature=features.get(i);
    if (feature instanceof CategoricalFeature) {
      loadCategoricalFeature(index,dataSet,(CategoricalFeature)feature,idTranslator);
    }
 else     if (feature instanceof Ngram) {
      loadNgramFeature(index,dataSet,(Ngram)feature,idTranslator);
    }
  }
);
}

Fixed version (ground truth):
public static void loadFeatures(ESIndex index,DataSet dataSet,FeatureList features,IdTranslator idTranslator){
  boolean[] toHandle=new boolean[features.size()];
  Arrays.fill(toHandle,true);
  for (int i=0; i < features.size(); i++) {
    Feature feature=features.get(i);
    if (toHandle[i]) {
      if (feature instanceof CategoricalFeature) {
        int numCategories=((CategoricalFeature)feature).getNumCategories();
        for (int pos=i + 1; pos < i + numCategories; pos++) {
          toHandle[pos]=false;
        }
      }
    }
  }
  IntStream.range(0,features.size()).parallel().filter(i -> toHandle[i]).forEach(i -> {
    Feature feature=features.get(i);
    if (feature instanceof CategoricalFeature) {
      loadCategoricalFeature(index,dataSet,(CategoricalFeature)feature,idTranslator);
    }
 else     if (feature instanceof Ngram) {
      loadNgramFeature(index,dataSet,(Ngram)feature,idTranslator);
    }
 else {
      loadNumericalFeature(index,dataSet,feature,idTranslator);
    }
  }
);
}
Program: 33031
Project: 33031
Buggy source:
public double score(Vector vector,int[] labels,int numClasses){
  List<List<Double>> inputsEachClass=generateInputsEachClass(vector,labels,numClasses);
  List<EmpiricalCDF> empiricalCDFs=generateCDFs(inputsEachClass);
  return maxDistance(empiricalCDFs);
}

Fixed version (ground truth):
public double score(Vector vector,int[] labels,int numClasses){
  List<List<Double>> inputsEachClass=generateInputsEachClass(vector,labels,numClasses);
  List<EmpiricalCDF> empiricalCDFs=generateCDFs(vector,inputsEachClass);
  return maxDistance(empiricalCDFs);
}
Program: 33032
Project: 33032
Buggy source:
List<List<Double>> generateInputsEachClass(Vector vector,int[] labels,int numClasses){
  Vector input;
  if (vector.isDense()) {
    input=vector;
  }
 else {
    input=new DenseVector(vector);
  }
  List<List<Double>> inputsEachClass=new ArrayList<>();
  for (int k=0; k < numClasses; k++) {
    inputsEachClass.add(new ArrayList<>());
  }
  for (int i=0; i < labels.length; i++) {
    int label=labels[i];
    inputsEachClass.get(label).add(input.get(i));
  }
  return inputsEachClass;
}

Fixed version (ground truth):
public List<List<Double>> generateInputsEachClass(Vector vector,int[] labels,int numClasses){
  Vector input;
  if (vector.isDense()) {
    input=vector;
  }
 else {
    input=new DenseVector(vector);
  }
  List<List<Double>> inputsEachClass=new ArrayList<>();
  for (int k=0; k < numClasses; k++) {
    inputsEachClass.add(new ArrayList<>());
  }
  for (int i=0; i < labels.length; i++) {
    int label=labels[i];
    inputsEachClass.get(label).add(input.get(i));
  }
  return inputsEachClass;
}