nus-yam/ex-repair huggingface dataset:
Program: 31687
Project: 31687
Buggy source:
@Override public void run(){
  List<TreeNode> subTrees=trees.subList(0,trees.size() - 1);
  Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
  if (!context.getMasterResult().isHalt() && context.getCurrentIteration() != context.getTotalIteration()) {
    writeModelToFileSystem(subTrees,out);
  }
  saveTmpModelToHDFS(subTrees.size(),subTrees);
}

Fixed version (ground truth):
@Override public void run(){
  List<TreeNode> subTrees=trees.subList(0,trees.size() - 1);
  Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
  if (!isHalt && currentIteration != totalIteration) {
    writeModelToFileSystem(subTrees,out);
  }
  saveTmpModelToHDFS(subTrees.size(),subTrees);
}
Program: 31688
Project: 31688
Buggy source:
@Override public void postIteration(final MasterContext<LogisticRegressionParams,LogisticRegressionParams> context){
  if (this.isDry) {
    return;
  }
  double currentError=((modelConfig.getTrain().getValidSetRate() < EPSILON) ? context.getMasterResult().getTrainError() : context.getMasterResult().getTestError());
  if (currentError < this.minTestError) {
    this.minTestError=currentError;
    this.optimizedWeights=context.getMasterResult().getParameters();
  }
  if (context.getCurrentIteration() % DTrainUtils.tmpModelFactor(context.getTotalIteration()) == 0) {
    Thread tmpNNThread=new Thread(new Runnable(){
      @Override public void run(){
        saveTmpModelToHDFS(context.getCurrentIteration(),context.getMasterResult().getParameters());
        Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
        if (!context.getMasterResult().isHalt() && context.getCurrentIteration() != context.getTotalIteration()) {
          writeModelWeightsToFileSystem(optimizedWeights,out);
        }
      }
    }
,"String_Node_Str");
    tmpNNThread.setDaemon(true);
    tmpNNThread.start();
  }
  updateProgressLog(context);
}

Fixed version (ground truth):
@Override public void postIteration(final MasterContext<LogisticRegressionParams,LogisticRegressionParams> context){
  if (this.isDry) {
    return;
  }
  double currentError=((modelConfig.getTrain().getValidSetRate() < EPSILON) ? context.getMasterResult().getTrainError() : context.getMasterResult().getTestError());
  if (currentError < this.minTestError) {
    this.minTestError=currentError;
    this.optimizedWeights=context.getMasterResult().getParameters();
  }
  final int tmpModelFactor=DTrainUtils.tmpModelFactor(context.getTotalIteration());
  final int currentIteration=context.getCurrentIteration();
  final double[] parameters=context.getMasterResult().getParameters();
  final int totalIteration=context.getTotalIteration();
  final boolean isHalt=context.getMasterResult().isHalt();
  if ((currentIteration - 1) % tmpModelFactor == 0) {
    Thread tmpNNThread=new Thread(new Runnable(){
      @Override public void run(){
        saveTmpModelToHDFS(currentIteration - 1,parameters);
        Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
        if (!isHalt && currentIteration != totalIteration) {
          writeModelWeightsToFileSystem(optimizedWeights,out);
        }
      }
    }
,"String_Node_Str");
    tmpNNThread.setDaemon(true);
    tmpNNThread.start();
  }
  updateProgressLog(context);
}
Program: 31689
Project: 31689
Buggy source:
@Override public void run(){
  saveTmpModelToHDFS(context.getCurrentIteration(),context.getMasterResult().getParameters());
  Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
  if (!context.getMasterResult().isHalt() && context.getCurrentIteration() != context.getTotalIteration()) {
    writeModelWeightsToFileSystem(optimizedWeights,out);
  }
}

Fixed version (ground truth):
@Override public void run(){
  saveTmpModelToHDFS(currentIteration - 1,parameters);
  Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
  if (!isHalt && currentIteration != totalIteration) {
    writeModelWeightsToFileSystem(optimizedWeights,out);
  }
}
Program: 31690
Project: 31690
Buggy source:
@Override public void postIteration(final MasterContext<NNParams,NNParams> context){
  if (this.isDry) {
    return;
  }
  double currentError=((modelConfig.getTrain().getValidSetRate() < EPSILON) ? context.getMasterResult().getTrainError() : context.getMasterResult().getTestError());
  if (currentError < this.minTestError) {
    this.minTestError=currentError;
    this.optimizedWeights=context.getMasterResult().getWeights();
  }
  final int tmpModelFactor=DTrainUtils.tmpModelFactor(context.getTotalIteration());
  if (context.getCurrentIteration() % tmpModelFactor == 0) {
    Thread tmpNNThread=new Thread(new Runnable(){
      @Override public void run(){
        saveTmpNNToHDFS(context.getCurrentIteration(),context.getMasterResult().getWeights());
        Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
        if (!context.getMasterResult().isHalt() && context.getCurrentIteration() != context.getTotalIteration()) {
          writeModelWeightsToFileSystem(optimizedWeights,out);
        }
      }
    }
,"String_Node_Str");
    tmpNNThread.setDaemon(true);
    tmpNNThread.start();
  }
  updateProgressLog(context);
}

Fixed version (ground truth):
@Override public void postIteration(final MasterContext<NNParams,NNParams> context){
  if (this.isDry) {
    return;
  }
  double currentError=((modelConfig.getTrain().getValidSetRate() < EPSILON) ? context.getMasterResult().getTrainError() : context.getMasterResult().getTestError());
  if (currentError < this.minTestError) {
    this.minTestError=currentError;
    this.optimizedWeights=context.getMasterResult().getWeights();
  }
  final int tmpModelFactor=DTrainUtils.tmpModelFactor(context.getTotalIteration());
  final int currentIteration=context.getCurrentIteration();
  final double[] weights=context.getMasterResult().getWeights();
  final int totalIteration=context.getTotalIteration();
  final boolean isHalt=context.getMasterResult().isHalt();
  if (currentIteration > 1 && (currentIteration - 1) % tmpModelFactor == 0) {
    Thread tmpNNThread=new Thread(new Runnable(){
      @Override public void run(){
        saveTmpNNToHDFS(currentIteration - 1,weights);
        Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
        if (!isHalt && currentIteration != totalIteration) {
          writeModelWeightsToFileSystem(optimizedWeights,out);
        }
      }
    }
,"String_Node_Str");
    tmpNNThread.setDaemon(true);
    tmpNNThread.start();
  }
  updateProgressLog(context);
}
Program: 31691
Project: 31691
Buggy source:
@Override public void run(){
  saveTmpNNToHDFS(context.getCurrentIteration(),context.getMasterResult().getWeights());
  Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
  if (!context.getMasterResult().isHalt() && context.getCurrentIteration() != context.getTotalIteration()) {
    writeModelWeightsToFileSystem(optimizedWeights,out);
  }
}

Fixed version (ground truth):
@Override public void run(){
  saveTmpNNToHDFS(currentIteration - 1,weights);
  Path out=new Path(context.getProps().getProperty(CommonConstants.GUAGUA_OUTPUT));
  if (!isHalt && currentIteration != totalIteration) {
    writeModelWeightsToFileSystem(optimizedWeights,out);
  }
}
Program: 31692
Project: 31692
Buggy source:
/** 
 * Get feature importance of current model.
 * @return map of feature importance, key is column index.
 */
public Map<Integer,MutablePair<String,Double>> getFeatureImportances(){
  Map<Integer,MutablePair<String,Double>> importancesSum=new HashMap<Integer,MutablePair<String,Double>>();
  Map<Integer,String> nameMapping=this.getIndependentTreeModel().getNumNameMapping();
  int size=this.getIndependentTreeModel().getTrees().size();
  for (  TreeNode tree : this.getIndependentTreeModel().getTrees()) {
    Map<Integer,Double> subImportances=tree.computeFeatureImportance();
    for (    Entry<Integer,Double> entry : subImportances.entrySet()) {
      String featureName=nameMapping.get(entry.getKey());
      MutablePair<String,Double> importance=MutablePair.of(featureName,entry.getValue());
      if (!importancesSum.containsKey(entry.getKey())) {
        importance.setValue(importance.getValue() / size);
        importancesSum.put(entry.getKey(),importance);
      }
 else {
        MutablePair<String,Double> current=importancesSum.get(entry.getKey());
        current.setValue(current.getValue() + importance.getValue() / size);
        importancesSum.put(entry.getKey(),current);
      }
    }
  }
  return importancesSum;
}

Fixed version (ground truth):
/** 
 * Get feature importance of current model.
 * @return map of feature importance, key is column index.
 */
public Map<Integer,MutablePair<String,Double>> getFeatureImportances(){
  Map<Integer,MutablePair<String,Double>> importancesSum=new HashMap<Integer,MutablePair<String,Double>>();
  Map<Integer,String> nameMapping=this.getIndependentTreeModel().getNumNameMapping();
  int treeSize=this.getIndependentTreeModel().getTrees().size();
  for (  TreeNode tree : this.getIndependentTreeModel().getTrees()) {
    Map<Integer,Double> subImportances=tree.computeFeatureImportance();
    for (    Entry<Integer,Double> entry : subImportances.entrySet()) {
      String featureName=nameMapping.get(entry.getKey());
      MutablePair<String,Double> importance=MutablePair.of(featureName,entry.getValue());
      if (!importancesSum.containsKey(entry.getKey())) {
        importance.setValue(importance.getValue() / treeSize);
        importancesSum.put(entry.getKey(),importance);
      }
 else {
        MutablePair<String,Double> current=importancesSum.get(entry.getKey());
        current.setValue(current.getValue() + importance.getValue() / treeSize);
        importancesSum.put(entry.getKey(),current);
      }
    }
  }
  return importancesSum;
}
Program: 31693
Project: 31693
Buggy source:
/** 
 * Locate histogram unit with just less than s, from some histogram unit
 * @param s the s value
 * @param startPos start pos
 * @return next node
 */
private LinkNode<HistogramUnit> locateHistogram(double s,LinkNode<HistogramUnit> startPos){
  while (startPos != this.tail) {
    if (startPos == null) {
      startPos=this.header;
    }
    HistogramUnit chu=startPos.data();
    HistogramUnit nhu=startPos.next().data();
    double sc=sumCache.get(startPos);
    double sn=sumCache.get(startPos.next());
    if (sc >= s || (sc < s && s <= sn)) {
      return startPos;
    }
    startPos=startPos.next();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Locate histogram unit with just less than s, from some histogram unit
 * @param s the s value
 * @param startPos start pos
 * @return next node
 */
private LinkNode<HistogramUnit> locateHistogram(double s,LinkNode<HistogramUnit> startPos){
  while (startPos != this.tail) {
    if (startPos == null) {
      startPos=this.header;
    }
    double sc=sumCache.get(startPos);
    double sn=sumCache.get(startPos.next());
    if (sc >= s || (sc < s && s <= sn)) {
      return startPos;
    }
    startPos=startPos.next();
  }
  return null;
}
Program: 31694
Project: 31694
Buggy source:
/** 
 * Sum the histogram's frequency whose value less than or equal some value
 * @param hval the h value
 * @return current sum
 */
private double sum(double hval){
  LinkNode<HistogramUnit> posHistogramUnit=null;
  LinkNode<HistogramUnit> tmp=this.header;
  while (tmp != this.tail) {
    HistogramUnit chu=tmp.data();
    HistogramUnit nhu=tmp.next().data();
    if (chu.getHval() <= hval && hval < nhu.getHval()) {
      posHistogramUnit=tmp;
      break;
    }
    tmp=tmp.next();
  }
  if (posHistogramUnit != null) {
    HistogramUnit chu=posHistogramUnit.data();
    HistogramUnit nhu=posHistogramUnit.next().data();
    double mb=chu.getHcnt() + (nhu.getHcnt() - chu.getHcnt()) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    double s=(chu.getHcnt() + mb) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    s=s / 2;
    tmp=this.header;
    while (tmp != posHistogramUnit) {
      HistogramUnit hu=tmp.data();
      s=s + hu.getHcnt();
      tmp=tmp.next();
    }
    return s + chu.getHcnt() / 2d;
  }
 else   if (tmp == this.tail) {
    double sum=0.0;
    tmp=this.header;
    while (tmp != null) {
      sum+=tmp.data().getHcnt();
      tmp=tmp.next();
    }
    return sum;
  }
  return -1.0;
}

Fixed version (ground truth):
/** 
 * Sum the histogram's frequency whose value less than or equal some value
 * @param hval the h value
 * @return current sum
 */
@SuppressWarnings("String_Node_Str") private double sum(double hval){
  LinkNode<HistogramUnit> posHistogramUnit=null;
  LinkNode<HistogramUnit> tmp=this.header;
  while (tmp != this.tail) {
    HistogramUnit chu=tmp.data();
    HistogramUnit nhu=tmp.next().data();
    if (chu.getHval() <= hval && hval < nhu.getHval()) {
      posHistogramUnit=tmp;
      break;
    }
    tmp=tmp.next();
  }
  if (posHistogramUnit != null) {
    HistogramUnit chu=posHistogramUnit.data();
    HistogramUnit nhu=posHistogramUnit.next().data();
    double mb=chu.getHcnt() + (nhu.getHcnt() - chu.getHcnt()) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    double s=(chu.getHcnt() + mb) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    s=s / 2;
    tmp=this.header;
    while (tmp != posHistogramUnit) {
      HistogramUnit hu=tmp.data();
      s=s + hu.getHcnt();
      tmp=tmp.next();
    }
    return s + chu.getHcnt() / 2d;
  }
 else   if (tmp == this.tail) {
    double sum=0.0;
    tmp=this.header;
    while (tmp != null) {
      sum+=tmp.data().getHcnt();
      tmp=tmp.next();
    }
    return sum;
  }
  return -1.0;
}
Program: 31695
Project: 31695
Buggy source:
private void populateGainInfoToNode(int treeId,Node doneNode,GainInfo maxGainInfo){
  doneNode.setPredict(maxGainInfo.getPredict());
  doneNode.setSplit(maxGainInfo.getSplit());
  doneNode.setGain(maxGainInfo.getGain());
  doneNode.setImpurity(maxGainInfo.getImpurity());
  doneNode.setLeftImpurity(maxGainInfo.getLeftImpurity());
  doneNode.setRightImpurity(maxGainInfo.getRightImpurity());
  doneNode.setLeftPredict(maxGainInfo.getLeftPredict());
  doneNode.setRightPredict(maxGainInfo.getRightPredict());
  if (Node.isRootNode(doneNode)) {
    this.trees.get(treeId).setRootWgtCnt(maxGainInfo.getWgtCnt());
  }
 else {
    double rootWgtCnt=this.trees.get(treeId).getRootWgtCnt();
    doneNode.setWgtCntRatio(maxGainInfo.getWgtCnt() / rootWgtCnt);
  }
}

Fixed version (ground truth):
private void populateGainInfoToNode(int treeId,Node doneNode,GainInfo maxGainInfo){
  doneNode.setPredict(maxGainInfo.getPredict());
  doneNode.setSplit(maxGainInfo.getSplit());
  doneNode.setGain(maxGainInfo.getGain());
  doneNode.setImpurity(maxGainInfo.getImpurity());
  doneNode.setLeftImpurity(maxGainInfo.getLeftImpurity());
  doneNode.setRightImpurity(maxGainInfo.getRightImpurity());
  doneNode.setLeftPredict(maxGainInfo.getLeftPredict());
  doneNode.setRightPredict(maxGainInfo.getRightPredict());
  doneNode.setWgtCnt(maxGainInfo.getWgtCnt());
  if (Node.isRootNode(doneNode)) {
    this.trees.get(treeId).setRootWgtCnt(maxGainInfo.getWgtCnt());
  }
 else {
    double rootWgtCnt=this.trees.get(treeId).getRootWgtCnt();
    doneNode.setWgtCntRatio(maxGainInfo.getWgtCnt() / rootWgtCnt);
  }
}
Program: 31696
Project: 31696
Buggy source:
public IndependentTreeModel(Map<Integer,Double> numericalMeanMapping,Map<Integer,String> numNameMapping,Map<Integer,List<String>> categoricalColumnNameNames,Map<Integer,Map<String,Integer>> columnCategoryIndexMapping,Map<Integer,Integer> columnNumIndexMapping,boolean isOptimizeMode,List<TreeNode> trees,List<Double> weights,boolean isGBDT,boolean isClassification,boolean isConvertToProb,String lossStr,String algorithm,int inputNode,int version){
  this.numericalMeanMapping=numericalMeanMapping;
  this.numNameMapping=numNameMapping;
  this.categoricalColumnNameNames=categoricalColumnNameNames;
  this.columnCategoryIndexMapping=columnCategoryIndexMapping;
  this.columnNumIndexMapping=columnNumIndexMapping;
  this.isOptimizeMode=isOptimizeMode;
  this.trees=trees;
  this.weights=weights;
  this.isGBDT=isGBDT;
  this.isClassification=isClassification;
  this.isConvertToProb=isConvertToProb;
  this.lossStr=lossStr;
  this.algorithm=algorithm;
  this.inputNode=inputNode;
  this.version=version;
  if (this.isOptimizeMode) {
    this.categoricalValueSize=new int[this.columnNumIndexMapping.size()];
    Iterator<Entry<Integer,List<String>>> iterator=this.categoricalColumnNameNames.entrySet().iterator();
    while (iterator.hasNext()) {
      Entry<Integer,List<String>> entry=iterator.next();
      Integer columnNum=entry.getKey();
      if (this.columnNumIndexMapping.containsKey(columnNum)) {
        this.categoricalValueSize[this.columnNumIndexMapping.get(columnNum)]=entry.getValue().size();
      }
    }
  }
}

Fixed version (ground truth):
public IndependentTreeModel(Map<Integer,Double> numericalMeanMapping,Map<Integer,String> numNameMapping,Map<Integer,List<String>> categoricalColumnNameNames,Map<Integer,Map<String,Integer>> columnCategoryIndexMapping,Map<Integer,Integer> columnNumIndexMapping,boolean isOptimizeMode,List<TreeNode> trees,List<Double> weights,boolean isGBDT,boolean isClassification,boolean isConvertToProb,String lossStr,String algorithm,int inputNode,int version){
  this.numericalMeanMapping=numericalMeanMapping;
  this.numNameMapping=numNameMapping;
  this.categoricalColumnNameNames=categoricalColumnNameNames;
  this.columnCategoryIndexMapping=columnCategoryIndexMapping;
  this.columnNumIndexMapping=columnNumIndexMapping;
  this.isOptimizeMode=isOptimizeMode;
  this.trees=trees;
  this.weights=weights;
  this.isGBDT=isGBDT;
  this.isClassification=isClassification;
  this.isConvertToProb=isConvertToProb;
  this.lossStr=lossStr;
  this.algorithm=algorithm;
  this.inputNode=inputNode;
  IndependentTreeModel.version=version;
  if (this.isOptimizeMode) {
    this.categoricalValueSize=new int[this.columnNumIndexMapping.size()];
    Iterator<Entry<Integer,List<String>>> iterator=this.categoricalColumnNameNames.entrySet().iterator();
    while (iterator.hasNext()) {
      Entry<Integer,List<String>> entry=iterator.next();
      Integer columnNum=entry.getKey();
      if (this.columnNumIndexMapping.containsKey(columnNum)) {
        this.categoricalValueSize[this.columnNumIndexMapping.get(columnNum)]=entry.getValue().size();
      }
    }
  }
}
Program: 31697
Project: 31697
Buggy source:
/** 
 * @return the version
 */
public int getVersion(){
  return version;
}

Fixed version (ground truth):
public static int getVersion(){
  return version;
}
Program: 31698
Project: 31698
Buggy source:
/** 
 * @param version the version to set
 */
public void setVersion(int version){
  this.version=version;
}

Fixed version (ground truth):
public static void setVersion(int from){
  version=from;
}
Program: 31700
Project: 31700
Buggy source:
/** 
 * @return the wgtCnt
 */
public double getWgtCntRatio(){
  return this.nodeStats.getWgtCntRatio();
}

Fixed version (ground truth):
public double getWgtCntRatio(){
  return this.nodeStats.getWgtCntRatio();
}
Program: 31701
Project: 31701
Buggy source:
@Override public void write(DataOutput out) throws IOException {
  out.writeInt(id);
  out.writeFloat((float)gain);
  out.writeFloat((float)1d);
  if (split == null) {
    out.writeBoolean(false);
  }
 else {
    out.writeBoolean(true);
    split.write(out);
  }
  boolean isRealLeaf=isRealLeaf();
  out.writeBoolean(isRealLeaf);
  if (isRealLeaf) {
    if (predict == null) {
      out.writeBoolean(false);
    }
 else {
      out.writeBoolean(true);
      predict.write(out);
    }
  }
  if (left == null) {
    out.writeBoolean(false);
  }
 else {
    out.writeBoolean(true);
    left.write(out);
  }
  if (right == null) {
    out.writeBoolean(false);
  }
 else {
    out.writeBoolean(true);
    right.write(out);
  }
}

Fixed version (ground truth):
@Override public void write(DataOutput out) throws IOException {
  out.writeInt(id);
  out.writeFloat((float)gain);
  out.writeDouble(this.wgtCnt);
  if (split == null) {
    out.writeBoolean(false);
  }
 else {
    out.writeBoolean(true);
    split.write(out);
  }
  boolean isRealLeaf=isRealLeaf();
  out.writeBoolean(isRealLeaf);
  if (isRealLeaf) {
    if (predict == null) {
      out.writeBoolean(false);
    }
 else {
      out.writeBoolean(true);
      predict.write(out);
    }
  }
  if (left == null) {
    out.writeBoolean(false);
  }
 else {
    out.writeBoolean(true);
    left.write(out);
  }
  if (right == null) {
    out.writeBoolean(false);
  }
 else {
    out.writeBoolean(true);
    right.write(out);
  }
}
Program: 31702
Project: 31702
Buggy source:
@Override public void readFields(DataInput in) throws IOException {
  this.id=in.readInt();
  this.gain=in.readFloat();
  in.readFloat();
  if (in.readBoolean()) {
    this.split=new Split();
    this.split.readFields(in);
  }
  boolean isRealLeaf=in.readBoolean();
  if (isRealLeaf) {
    if (in.readBoolean()) {
      this.predict=new Predict();
      this.predict.readFields(in);
    }
  }
  if (in.readBoolean()) {
    this.left=new Node();
    this.left.readFields(in);
  }
  if (in.readBoolean()) {
    this.right=new Node();
    this.right.readFields(in);
  }
}

Fixed version (ground truth):
@Override public void readFields(DataInput in) throws IOException {
  this.id=in.readInt();
  this.gain=in.readFloat();
  if (IndependentTreeModel.getVersion() <= 2) {
    this.wgtCnt=in.readFloat();
  }
 else {
    this.wgtCnt=in.readDouble();
  }
  if (in.readBoolean()) {
    this.split=new Split();
    this.split.readFields(in);
  }
  boolean isRealLeaf=in.readBoolean();
  if (isRealLeaf) {
    if (in.readBoolean()) {
      this.predict=new Predict();
      this.predict.readFields(in);
    }
  }
  if (in.readBoolean()) {
    this.left=new Node();
    this.left.readFields(in);
  }
  if (in.readBoolean()) {
    this.right=new Node();
    this.right.readFields(in);
  }
}
Program: 31703
Project: 31703
Buggy source:
/** 
 * @param wgtCntRatio the wgtCntRatio to set
 */
public void setWgtCntRatio(double wgtCntRatio){
  if (this.nodeStats == null) {
    this.nodeStats=new NodeStats();
  }
  this.nodeStats.setWgtCntRatio(wgtCntRatio);
}

Fixed version (ground truth):
public void setWgtCntRatio(double wgtCntRatio){
  if (this.nodeStats == null) {
    this.nodeStats=new NodeStats();
  }
  this.nodeStats.setWgtCntRatio(wgtCntRatio);
}
Program: 31704
Project: 31704
Buggy source:
private void computeImportance(Map<Integer,Double> importances,Node node){
  if (!node.isRealLeaf()) {
    int featureId=node.getSplit().getColumnNum();
    if (!importances.containsKey(featureId)) {
      importances.put(featureId,node.getGain());
    }
 else {
      importances.put(featureId,importances.get(featureId) + node.getGain());
    }
  }
}

Fixed version (ground truth):
private void computeImportance(Map<Integer,Double> importances,Node node,double rootWgtCnt){
  if (!node.isRealLeaf()) {
    int featureId=node.getSplit().getColumnNum();
    double contribution=(node.getGain() * node.getWgtCnt()) / rootWgtCnt;
    if (!importances.containsKey(featureId)) {
      importances.put(featureId,contribution);
    }
 else {
      importances.put(featureId,importances.get(featureId) + contribution);
    }
  }
}
Program: 31705
Project: 31705
Buggy source:
private void preOrder(Map<Integer,Double> importances,Node node){
  if (node == null) {
    return;
  }
  computeImportance(importances,node);
  preOrder(importances,node.getLeft());
  preOrder(importances,node.getRight());
}

Fixed version (ground truth):
private void preOrder(Map<Integer,Double> importances,Node node,double rootWgtCnt){
  if (node == null) {
    return;
  }
  computeImportance(importances,node,rootWgtCnt);
  preOrder(importances,node.getLeft(),rootWgtCnt);
  preOrder(importances,node.getRight(),rootWgtCnt);
}
Program: 31706
Project: 31706
Buggy source:
/** 
 * Compute tree model feature importance.
 * @return a map with (column_id, feature_importance.)
 */
public Map<Integer,Double> computeFeatureImportance(){
  Map<Integer,Double> importances=new HashMap<Integer,Double>();
  preOrder(importances,node);
  return importances;
}

Fixed version (ground truth):
/** 
 * Compute tree model feature importance by accumulating gain. Check scikit-learn for details: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_tree.pyx#L1056
 * @return a map with (column_id, feature_importance.)
 */
public Map<Integer,Double> computeFeatureImportance(){
  Map<Integer,Double> importances=new HashMap<Integer,Double>();
  double rootWgtCnt=node.getWgtCnt();
  preOrder(importances,node,rootWgtCnt);
  return importances;
}
Program: 31707
Project: 31707
Buggy source:
private static Map<Integer,MutablePair<String,Double>> mergeImportanceList(List<Map<Integer,MutablePair<String,Double>>> list){
  Map<Integer,MutablePair<String,Double>> finalResult=new HashMap<Integer,MutablePair<String,Double>>();
  int size=list.size();
  for (  Map<Integer,MutablePair<String,Double>> item : list) {
    for (    Entry<Integer,MutablePair<String,Double>> entry : item.entrySet()) {
      if (!finalResult.containsKey(entry.getKey())) {
        MutablePair<String,Double> value=MutablePair.of(entry.getValue().getKey(),entry.getValue().getValue() / size);
        finalResult.put(entry.getKey(),value);
      }
 else {
        MutablePair<String,Double> current=finalResult.get(entry.getKey());
        double entryValue=entry.getValue().getValue();
        current.setValue(current.getValue() + entryValue / size);
        finalResult.put(entry.getKey(),current);
      }
    }
  }
  return TreeModel.sortByValue(finalResult,false);
}

Fixed version (ground truth):
private static Map<Integer,MutablePair<String,Double>> mergeImportanceList(List<Map<Integer,MutablePair<String,Double>>> list){
  Map<Integer,MutablePair<String,Double>> finalResult=new HashMap<Integer,MutablePair<String,Double>>();
  int modelSize=list.size();
  for (  Map<Integer,MutablePair<String,Double>> item : list) {
    for (    Entry<Integer,MutablePair<String,Double>> entry : item.entrySet()) {
      if (!finalResult.containsKey(entry.getKey())) {
        MutablePair<String,Double> value=MutablePair.of(entry.getValue().getKey(),entry.getValue().getValue() / modelSize);
        finalResult.put(entry.getKey(),value);
      }
 else {
        MutablePair<String,Double> current=finalResult.get(entry.getKey());
        double entryValue=entry.getValue().getValue();
        current.setValue(current.getValue() + (entryValue / modelSize));
        finalResult.put(entry.getKey(),current);
      }
    }
  }
  return TreeModel.sortByValue(finalResult,false);
}
Program: 31708
Project: 31708
Buggy source:
public static Map<Integer,MutablePair<String,Double>> computeTreeModelFeatureImportance(List<BasicML> models){
  List<Map<Integer,MutablePair<String,Double>>> importanceList=new ArrayList<Map<Integer,MutablePair<String,Double>>>();
  for (  BasicML basicModel : models) {
    if (basicModel instanceof TreeModel) {
      TreeModel model=(TreeModel)basicModel;
      Map<Integer,MutablePair<String,Double>> importances=model.getFeatureImportances();
      importanceList.add(importances);
    }
  }
  if (importanceList.size() < 1) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return mergeImportanceList(importanceList);
}

Fixed version (ground truth):
/** 
 * Compute feature importance for all bagging tree models.
 * @param models the tree models, should be instance of TreeModel
 * @return feature importance per each column id
 * @throws IllegalStateException if no any feature importance from models
 */
public static Map<Integer,MutablePair<String,Double>> computeTreeModelFeatureImportance(List<BasicML> models){
  List<Map<Integer,MutablePair<String,Double>>> importanceList=new ArrayList<Map<Integer,MutablePair<String,Double>>>();
  for (  BasicML basicModel : models) {
    if (basicModel instanceof TreeModel) {
      TreeModel model=(TreeModel)basicModel;
      Map<Integer,MutablePair<String,Double>> importances=model.getFeatureImportances();
      importanceList.add(importances);
    }
  }
  if (importanceList.size() < 1) {
    throw new IllegalStateException("String_Node_Str");
  }
  return mergeImportanceList(importanceList);
}
Program: 31709
Project: 31709
Buggy source:
public static TreeModel loadFromStream(InputStream input,boolean isConvertToProb,boolean isOptimizeMode) throws IOException {
  return new TreeModel(IndependentTreeModel.loadFromStream(input,isConvertToProb,isOptimizeMode));
}

Fixed version (ground truth):
public static TreeModel loadFromStream(InputStream input,boolean isConvertToProb,boolean isOptimizeMode,boolean isRemoveNameSpace) throws IOException {
  return new TreeModel(IndependentTreeModel.loadFromStream(input,isConvertToProb,isOptimizeMode,isRemoveNameSpace));
}
Program: 31714
Project: 31714
Buggy source:
/** 
 * Process one level.
 * @param currentLevel The current level.
 */
private void processLevel(final int currentLevel){
  final int fromLayerIndex=this.layerIndex[currentLevel + 1];
  final int toLayerIndex=this.layerIndex[currentLevel];
  final int fromLayerSize=this.layerCounts[currentLevel + 1];
  final int toLayerSize=this.layerFeedCounts[currentLevel];
  double dropoutRate=0;
  if (this.layerDropoutRates.length > currentLevel && this.layerDropoutRates[currentLevel] != 0) {
    dropoutRate=this.layerDropoutRates[currentLevel];
  }
  final int index=this.weightIndex[currentLevel];
  final ActivationFunction activation=this.getNetwork().getActivationFunctions()[currentLevel + 1];
  final double currentFlatSpot=this.flatSpot[currentLevel + 1];
  int yi=fromLayerIndex;
  for (int y=0; y < fromLayerSize; y++) {
    final double output=this.layerOutput[yi];
    double sum=0;
    int xi=toLayerIndex;
    int wi=index + y;
    for (int x=0; x < toLayerSize; x++) {
      if (this.owner.isELM() && currentLevel == 0) {
        this.gradients[wi]=0d;
      }
 else {
        this.gradients[wi]+=output * this.getLayerDelta()[xi];
      }
      sum+=this.weights[wi] * this.getLayerDelta()[xi];
      wi+=fromLayerSize;
      xi++;
    }
    if (dropoutRate == 0d || dropoutRandomSource.nextDouble() > dropoutRate) {
      this.getLayerDelta()[yi]=sum * (activation.derivativeFunction(this.layerSums[yi],this.layerOutput[yi]) + currentFlatSpot);
    }
 else {
      this.getLayerDelta()[yi]=0;
    }
    yi++;
  }
}

Fixed version (ground truth):
/** 
 * Process one level.
 * @param currentLevel The current level.
 */
private void processLevel(final int currentLevel){
  final int fromLayerIndex=this.layerIndex[currentLevel + 1];
  final int toLayerIndex=this.layerIndex[currentLevel];
  final int fromLayerSize=this.layerCounts[currentLevel + 1];
  final int toLayerSize=this.layerFeedCounts[currentLevel];
  double dropoutRate=0;
  if (this.layerDropoutRates.length > currentLevel && this.layerDropoutRates[currentLevel] != 0) {
    dropoutRate=this.layerDropoutRates[currentLevel];
  }
  final int index=this.weightIndex[currentLevel];
  final ActivationFunction activation=this.getNetwork().getActivationFunctions()[currentLevel + 1];
  final double currentFlatSpot=this.flatSpot[currentLevel + 1];
  int yi=fromLayerIndex;
  for (int y=0; y < fromLayerSize; y++) {
    final double output=this.layerOutput[yi];
    double sum=0;
    int wi=index + y;
    if (this.owner.isELM() || dropoutRate == 0d || dropoutRandomSource.nextDouble() > dropoutRate) {
      int xi=toLayerIndex;
      for (int x=0; x < toLayerSize; x++) {
        if (this.owner.isELM() && currentLevel == 0) {
          this.gradients[wi]=0d;
        }
 else {
          this.gradients[wi]+=output * this.getLayerDelta()[xi];
        }
        sum+=this.weights[wi] * this.getLayerDelta()[xi];
        wi+=fromLayerSize;
        xi++;
      }
      this.getLayerDelta()[yi]=sum * (activation.derivativeFunction(this.layerSums[yi],this.layerOutput[yi]) + currentFlatSpot);
    }
 else {
      this.getLayerDelta()[yi]=0;
    }
    yi++;
  }
}
Program: 31718
Project: 31718
Buggy source:
/** 
 * Write column info to reducer for merging.
 */
@Override protected void cleanup(Context context) throws IOException, InterruptedException {
  LOG.debug("String_Node_Str",this.columnBinningInfo);
  LOG.debug("String_Node_Str",this.variableCountMap);
  for (  Map.Entry<Integer,BinningInfoWritable> entry : this.columnBinningInfo.entrySet()) {
    CountAndFrequentItems cfi=this.variableCountMap.get(entry.getKey());
    if (cfi != null) {
      entry.getValue().setCfiw(new CountAndFrequentItemsWritable(cfi.getCount(),cfi.getInvalidCount(),cfi.getValidNumCount(),cfi.getHyper().getBytes(),cfi.getFrequentItems()));
    }
 else {
      LOG.info("String_Node_Str",entry.getKey());
    }
    this.outputKey.set(entry.getKey());
    context.write(this.outputKey,entry.getValue());
  }
}

Fixed version (ground truth):
/** 
 * Write column info to reducer for merging.
 */
@Override protected void cleanup(Context context) throws IOException, InterruptedException {
  LOG.debug("String_Node_Str",this.columnBinningInfo);
  LOG.debug("String_Node_Str",this.variableCountMap);
  for (  Map.Entry<Integer,BinningInfoWritable> entry : this.columnBinningInfo.entrySet()) {
    CountAndFrequentItems cfi=this.variableCountMap.get(entry.getKey());
    if (cfi != null) {
      entry.getValue().setCfiw(new CountAndFrequentItemsWritable(cfi.getCount(),cfi.getInvalidCount(),cfi.getValidNumCount(),cfi.getHyper().getBytes(),cfi.getFrequentItems()));
    }
 else {
      entry.getValue().setEmpty(true);
      LOG.warn("String_Node_Str",entry.getKey());
    }
    this.outputKey.set(entry.getKey());
    context.write(this.outputKey,entry.getValue());
  }
}
Program: 31727
Project: 31727
Buggy source:
/** 
 * Sum the histogram's frequency whose value less than or equal some value
 * @param hval the h value
 * @return current sum
 */
private double sum(double hval){
  LinkNode<HistogramUnit> posHistogramUnit=null;
  LinkNode<HistogramUnit> tmp=this.header;
  while (tmp != this.tail) {
    HistogramUnit chu=tmp.data();
    HistogramUnit nhu=tmp.next().data();
    if (chu.getHval() <= hval && hval < nhu.getHval()) {
      posHistogramUnit=tmp;
      break;
    }
    tmp=tmp.next();
  }
  if (posHistogramUnit != null) {
    HistogramUnit chu=posHistogramUnit.data();
    HistogramUnit nhu=posHistogramUnit.next().data();
    double mb=chu.getHcnt() + (nhu.getHcnt() - nhu.getHcnt()) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    double s=(chu.getHcnt() + mb) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    s=s / 2;
    tmp=this.header;
    while (tmp != posHistogramUnit) {
      HistogramUnit hu=tmp.data();
      s=s + hu.getHcnt();
      tmp=tmp.next();
    }
    return s + chu.getHcnt() / 2d;
  }
 else   if (tmp == this.tail) {
    double sum=0.0;
    tmp=this.header;
    while (tmp != null) {
      sum+=tmp.data().getHcnt();
      tmp=tmp.next();
    }
    return sum;
  }
  return -1.0;
}

Fixed version (ground truth):
/** 
 * Sum the histogram's frequency whose value less than or equal some value
 * @param hval the h value
 * @return current sum
 */
private double sum(double hval){
  LinkNode<HistogramUnit> posHistogramUnit=null;
  LinkNode<HistogramUnit> tmp=this.header;
  while (tmp != this.tail) {
    HistogramUnit chu=tmp.data();
    HistogramUnit nhu=tmp.next().data();
    if (chu.getHval() <= hval && hval < nhu.getHval()) {
      posHistogramUnit=tmp;
      break;
    }
    tmp=tmp.next();
  }
  if (posHistogramUnit != null) {
    HistogramUnit chu=posHistogramUnit.data();
    HistogramUnit nhu=posHistogramUnit.next().data();
    double mb=chu.getHcnt() + (nhu.getHcnt() - chu.getHcnt()) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    double s=(chu.getHcnt() + mb) * (hval - chu.getHval()) / (nhu.getHval() - chu.getHval());
    s=s / 2;
    tmp=this.header;
    while (tmp != posHistogramUnit) {
      HistogramUnit hu=tmp.data();
      s=s + hu.getHcnt();
      tmp=tmp.next();
    }
    return s + chu.getHcnt() / 2d;
  }
 else   if (tmp == this.tail) {
    double sum=0.0;
    tmp=this.header;
    while (tmp != null) {
      sum+=tmp.data().getHcnt();
      tmp=tmp.next();
    }
    return sum;
  }
  return -1.0;
}
Program: 31728
Project: 31728
Buggy source:
/** 
 * Parse raw value based on ColumnConfig.
 * @param config ColumnConfig info
 * @param raw input column value
 * @param categoryMissingNormType missing categorical value norm type
 * @return parsed raw value. For categorical type, return BinPosRate. For numerical type, returncorresponding double value. For missing data, return default value using {@link Normalizer#defaultMissingValue}.
 */
private static double parseRawValue(ColumnConfig config,String raw,CategoryMissingNormType categoryMissingNormType){
  if (categoryMissingNormType == null) {
    categoryMissingNormType=CategoryMissingNormType.MEAN;
  }
  double value=0.0;
  if (config.isCategorical()) {
    int index=CommonUtils.getBinNum(config,raw);
    if (index == -1) {
switch (categoryMissingNormType) {
case POSRATE:
        value=config.getBinPosRate().get(config.getBinPosRate().size() - 1);
      break;
case MEAN:
default :
    value=defaultMissingValue(config);
  break;
}
}
 else {
Double binPosRate=config.getBinPosRate().get(index);
value=binPosRate == null ? defaultMissingValue(config) : binPosRate.doubleValue();
}
}
 else {
try {
value=Double.parseDouble(raw);
}
 catch (Exception e) {
log.debug("String_Node_Str" + raw + "String_Node_Str");
value=defaultMissingValue(config);
}
}
return value;
}

Fixed version (ground truth):
/** 
 * Parse raw value based on ColumnConfig.
 * @param config ColumnConfig info
 * @param raw input column value
 * @param categoryMissingNormType missing categorical value norm type
 * @return parsed raw value. For categorical type, return BinPosRate. For numerical type, returncorresponding double value. For missing data, return default value using {@link Normalizer#defaultMissingValue}.
 */
private static double parseRawValue(ColumnConfig config,String raw,CategoryMissingNormType categoryMissingNormType){
  if (categoryMissingNormType == null) {
    categoryMissingNormType=CategoryMissingNormType.MEAN;
  }
  double value=0.0;
  if (config.isCategorical()) {
    int index=CommonUtils.getBinNum(config,raw);
    if (index == -1) {
switch (categoryMissingNormType) {
case POSRATE:
        value=config.getBinPosRate().get(config.getBinPosRate().size() - 1);
      break;
case MEAN:
default :
    value=defaultMissingValue(config);
  break;
}
}
 else {
Double binPosRate=config.getBinPosRate().get(index);
if (binPosRate != null) {
value=binPosRate.doubleValue();
;
}
 else {
switch (categoryMissingNormType) {
case POSRATE:
  value=config.getBinPosRate().get(config.getBinPosRate().size() - 1);
break;
case MEAN:
default :
value=defaultMissingValue(config);
break;
}
}
}
}
 else {
try {
value=Double.parseDouble(raw);
}
 catch (Exception e) {
log.debug("String_Node_Str" + raw + "String_Node_Str");
value=defaultMissingValue(config);
}
}
return value;
}
Program: 31733
Project: 31733
Buggy source:
/** 
 * Do checkpoint for master states, this is for master fail over
 */
private void doCheckPoint(final MasterContext<DTMasterParams,DTWorkerParams> context,final DTMasterParams masterParams,int iteration){
  LOG.info("String_Node_Str",this.checkpointOutput,iteration);
  final Queue<TreeNode> finalTodoQueue=this.toDoQueue;
  final Queue<TreeNode> finalToSplitQueue=this.toSplitQueue;
  final boolean finalIsLeaf=this.isLeafWise;
  long start=System.currentTimeMillis();
  final List<TreeNode> finalTrees=new ArrayList<TreeNode>();
  for (  TreeNode treeNode : this.trees) {
    BytableSerializer<TreeNode> bs=new BytableSerializer<TreeNode>();
    byte[] bytes=bs.objectToBytes(treeNode);
    TreeNode newTreeNode=bs.bytesToObject(bytes,TreeNode.class.getName());
    finalTrees.add(newTreeNode);
  }
  LOG.info("String_Node_Str",context.getCurrentIteration(),(System.currentTimeMillis() - start));
  Thread cpPersistThread=new Thread(new Runnable(){
    @Override public void run(){
      writeStatesToHdfs(DTMaster.this.checkpointOutput,masterParams,finalTrees,finalIsLeaf,finalTodoQueue,finalToSplitQueue);
    }
  }
,"String_Node_Str");
  cpPersistThread.setDaemon(true);
  cpPersistThread.start();
}

Fixed version (ground truth):
/** 
 * Do checkpoint for master states, this is for master fail over
 */
private void doCheckPoint(final MasterContext<DTMasterParams,DTWorkerParams> context,final DTMasterParams masterParams,int iteration){
  String intervalStr=context.getProps().getProperty(CommonConstants.SHIFU_TREE_CHECKPOINT_INTERVAL);
  int interval=50;
  try {
    interval=Integer.parseInt(intervalStr);
  }
 catch (  Exception ignore) {
  }
  if (iteration != 0 && iteration % interval != 0) {
    return;
  }
  LOG.info("String_Node_Str",this.checkpointOutput,iteration);
  final Queue<TreeNode> finalTodoQueue=this.toDoQueue;
  final Queue<TreeNode> finalToSplitQueue=this.toSplitQueue;
  final boolean finalIsLeaf=this.isLeafWise;
  long start=System.currentTimeMillis();
  final List<TreeNode> finalTrees=new ArrayList<TreeNode>();
  for (  TreeNode treeNode : this.trees) {
    BytableSerializer<TreeNode> bs=new BytableSerializer<TreeNode>();
    byte[] bytes=bs.objectToBytes(treeNode);
    TreeNode newTreeNode=bs.bytesToObject(bytes,TreeNode.class.getName());
    finalTrees.add(newTreeNode);
  }
  LOG.info("String_Node_Str",context.getCurrentIteration(),(System.currentTimeMillis() - start));
  Thread cpPersistThread=new Thread(new Runnable(){
    @Override public void run(){
      writeStatesToHdfs(DTMaster.this.checkpointOutput,masterParams,finalTrees,finalIsLeaf,finalTodoQueue,finalToSplitQueue);
    }
  }
,"String_Node_Str");
  cpPersistThread.setDaemon(true);
  cpPersistThread.start();
}
Program: 31734
Project: 31734
Buggy source:
/** 
 * Rollup feature importance file to keep latest one and old ones.
 */
private void processRollupForFIFiles(String localFsFolder){
  try {
    FileSystem fs=ShifuFileUtils.getFileSystemBySourceType(SourceType.LOCAL);
    if (!fs.isDirectory(new Path(localFsFolder))) {
      return;
    }
    FileStatus[] fss=fs.listStatus(new Path(localFsFolder));
    if (fss != null && fss.length > 0) {
      for (      FileStatus fileStatus : fss) {
        String strPath=fileStatus.getPath().getName();
        if (strPath.endsWith(PathFinder.FEATURE_IMPORTANCE_FILE)) {
          fs.rename(fileStatus.getPath(),new Path(fileStatus.getPath() + "String_Node_Str"));
        }
 else         if (strPath.contains(PathFinder.FEATURE_IMPORTANCE_FILE)) {
          int lastDotIndex=strPath.lastIndexOf("String_Node_Str");
          String lastIndexStr=strPath.substring(lastDotIndex + 1,strPath.length());
          int index=Integer.parseInt(lastIndexStr);
          fs.rename(fileStatus.getPath(),new Path(fileStatus.getPath() + "String_Node_Str" + (index + 1)));
        }
      }
    }
  }
 catch (  Exception ignore) {
  }
}

Fixed version (ground truth):
/** 
 * Rollup feature importance file to keep latest one and old ones.
 */
private void processRollupForFIFiles(String localFsFolder,String fiFile){
  try {
    FileSystem fs=ShifuFileUtils.getFileSystemBySourceType(SourceType.LOCAL);
    if (!fs.isDirectory(new Path(localFsFolder))) {
      return;
    }
    FileStatus[] fss=fs.listStatus(new Path(localFsFolder));
    Arrays.sort(fss,new Comparator<FileStatus>(){
      @Override public int compare(      FileStatus o1,      FileStatus o2){
        return o2.getPath().toString().compareTo(o1.getPath().toString());
      }
    }
);
    if (fss != null && fss.length > 0) {
      for (      FileStatus fileStatus : fss) {
        String strPath=fileStatus.getPath().getName();
        if (strPath.endsWith(PathFinder.FEATURE_IMPORTANCE_FILE)) {
          fs.rename(fileStatus.getPath(),new Path(fileStatus.getPath() + "String_Node_Str"));
        }
 else         if (strPath.contains(PathFinder.FEATURE_IMPORTANCE_FILE)) {
          int lastDotIndex=strPath.lastIndexOf("String_Node_Str");
          String lastIndexStr=strPath.substring(lastDotIndex + 1,strPath.length());
          int index=Integer.parseInt(lastIndexStr);
          fs.rename(fileStatus.getPath(),new Path(fiFile + "String_Node_Str" + (index + 1)));
        }
      }
    }
  }
 catch (  Exception ignore) {
  }
}
Program: 31736
Project: 31736
Buggy source:
@Override public LocalTransformations build(BasicML basicML){
  LocalTransformations localTransformations=new LocalTransformations();
  if (basicML instanceof BasicFloatNetwork) {
    BasicFloatNetwork bfn=(BasicFloatNetwork)basicML;
    Set<Integer> featureSet=bfn.getFeatureSet();
    for (    ColumnConfig config : columnConfigList) {
      if (config.isFinalSelect() && featureSet.contains(config.getColumnName())) {
        double cutoff=modelConfig.getNormalizeStdDevCutOff();
        localTransformations.withDerivedFields(config.isCategorical() ? createCategoricalDerivedField(config,cutoff,modelConfig.getNormalizeType()) : createNumericalDerivedField(config,cutoff,modelConfig.getNormalizeType()));
      }
    }
  }
 else {
    for (    ColumnConfig config : columnConfigList) {
      if (config.isFinalSelect()) {
        double cutoff=modelConfig.getNormalizeStdDevCutOff();
        localTransformations.withDerivedFields(config.isCategorical() ? createCategoricalDerivedField(config,cutoff,modelConfig.getNormalizeType()) : createNumericalDerivedField(config,cutoff,modelConfig.getNormalizeType()));
      }
    }
  }
  return localTransformations;
}

Fixed version (ground truth):
@Override public LocalTransformations build(BasicML basicML){
  LocalTransformations localTransformations=new LocalTransformations();
  if (basicML instanceof BasicFloatNetwork) {
    BasicFloatNetwork bfn=(BasicFloatNetwork)basicML;
    Set<Integer> featureSet=bfn.getFeatureSet();
    for (    ColumnConfig config : columnConfigList) {
      if (config.isFinalSelect() && (CollectionUtils.isEmpty(featureSet) || featureSet.contains(config.getColumnNum()))) {
        double cutoff=modelConfig.getNormalizeStdDevCutOff();
        localTransformations.withDerivedFields(config.isCategorical() ? createCategoricalDerivedField(config,cutoff,modelConfig.getNormalizeType()) : createNumericalDerivedField(config,cutoff,modelConfig.getNormalizeType()));
      }
    }
  }
 else {
    for (    ColumnConfig config : columnConfigList) {
      if (config.isFinalSelect()) {
        double cutoff=modelConfig.getNormalizeStdDevCutOff();
        localTransformations.withDerivedFields(config.isCategorical() ? createCategoricalDerivedField(config,cutoff,modelConfig.getNormalizeType()) : createNumericalDerivedField(config,cutoff,modelConfig.getNormalizeType()));
      }
    }
  }
  return localTransformations;
}
Program: 31739
Project: 31739
Buggy source:
/** 
 * Check some categorical value is in the categorical value group or not
 * @param binVal - categorical value group, the format is lik cn^us^uk^jp
 * @param cval - categorical value to look up
 * @return  true if the categorical value exists in group, else false
 */
public static boolean isCategoricalBinValue(String binVal,String cval){
  return binVal.equals(cval) ? true : CommonUtils.flattenCatValGrp(binVal).contains(cval);
}

Fixed version (ground truth):
/** 
 * Check some categorical value is in the categorical value group or not
 * @param binVal - categorical value group, the format is lik cn^us^uk^jp
 * @param cval - categorical value to look up
 * @return true if the categorical value exists in group, else false
 */
public static boolean isCategoricalBinValue(String binVal,String cval){
  return binVal.equals(cval) ? true : CommonUtils.flattenCatValGrp(binVal).contains(cval);
}
Program: 31740
Project: 31740
Buggy source:
/** 
 * Find the @ColumnConfig according the column name
 * @param columnConfigList list of column config
 * @param columnName the column name
 * @return column config instance
 */
public static ColumnConfig findColumnConfigByName(List<ColumnConfig> columnConfigList,String columnName){
  for (  ColumnConfig columnConfig : columnConfigList) {
    if (columnConfig.getColumnName().equalsIgnoreCase(columnName)) {
      return columnConfig;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Find the @ColumnConfig according the column name
 * @param columnConfigList list of column config
 * @param columnName the column name
 * @return column config instance
 */
public static ColumnConfig findColumnConfigByName(List<ColumnConfig> columnConfigList,String columnName){
  for (  ColumnConfig columnConfig : columnConfigList) {
    if (NSColumnUtils.isColumnEqual(columnConfig.getColumnName(),columnName)) {
      return columnConfig;
    }
  }
  return null;
}