Program: 42539
Project: 42539
Buggy source:
public List<?> predict() throws MLModelBuilderException {
  String algorithmType=model.getAlgorithmClass();
  if (MLConstants.CLASSIFICATION.equals(algorithmType)) {
    SUPERVISED_ALGORITHM supervised_algorithm=SUPERVISED_ALGORITHM.valueOf(model.getAlgorithmName());
    List<Double> predictions=new ArrayList<Double>();
switch (supervised_algorithm) {
case DECISION_TREE:
      DecisionTreeModel decisionTreeModel=(DecisionTreeModel)model.getModel();
    for (    Vector vector : dataToBePredicted) {
      double predictedData=decisionTreeModel.predict(vector);
      predictions.add(predictedData);
      log.info("String_Node_Str" + predictedData);
    }
default :
  ClassificationModel classificationModel=(ClassificationModel)model.getModel();
for (Vector vector : dataToBePredicted) {
  double predictedData=classificationModel.predict(vector);
  predictions.add(predictedData);
  log.info("String_Node_Str" + predictedData);
}
}
return predictions;
}
 else if (MLConstants.NUMERICAL_PREDICTION.equals(algorithmType)) {
GeneralizedLinearModel generalizedLinearModel=(GeneralizedLinearModel)model.getModel();
List<Double> predictions=new ArrayList<Double>();
for (Vector vector : dataToBePredicted) {
double predictedData=generalizedLinearModel.predict(vector);
predictions.add(predictedData);
log.info("String_Node_Str" + predictedData);
}
return predictions;
}
 else if (MLConstants.CLUSTERING.equals((algorithmType))) {
UNSUPERVISED_ALGORITHM unsupervised_algorithm=UNSUPERVISED_ALGORITHM.valueOf(model.getAlgorithmName());
switch (unsupervised_algorithm) {
case K_MEANS:
List<Integer> predictions=new ArrayList<Integer>();
KMeansModel kMeansModel=(KMeansModel)model.getModel();
for (Vector vector : dataToBePredicted) {
int predictedData=kMeansModel.predict(vector);
predictions.add(predictedData);
log.info("String_Node_Str" + predictedData);
}
return predictions;
default :
throw new AlgorithmNameException("String_Node_Str" + model.getAlgorithmName() + "String_Node_Str"+ id);
}
}
 else {
throw new MLModelBuilderException(String.format("String_Node_Str",id,algorithmType));
}
}

Fixed version (ground truth):
public List<?> predict() throws MLModelBuilderException {
  String algorithmType=model.getAlgorithmClass();
  if (MLConstants.CLASSIFICATION.equals(algorithmType)) {
    SUPERVISED_ALGORITHM supervised_algorithm=SUPERVISED_ALGORITHM.valueOf(model.getAlgorithmName());
    List<Double> predictions=new ArrayList<Double>();
switch (supervised_algorithm) {
case DECISION_TREE:
      DecisionTreeModel decisionTreeModel=(DecisionTreeModel)model.getModel();
    for (    Vector vector : dataToBePredicted) {
      double predictedData=decisionTreeModel.predict(vector);
      predictions.add(predictedData);
      log.info("String_Node_Str" + predictedData);
    }
  return predictions;
default :
ClassificationModel classificationModel=(ClassificationModel)model.getModel();
for (Vector vector : dataToBePredicted) {
double predictedData=classificationModel.predict(vector);
predictions.add(predictedData);
log.info("String_Node_Str" + predictedData);
}
return predictions;
}
}
 else if (MLConstants.NUMERICAL_PREDICTION.equals(algorithmType)) {
GeneralizedLinearModel generalizedLinearModel=(GeneralizedLinearModel)model.getModel();
List<Double> predictions=new ArrayList<Double>();
for (Vector vector : dataToBePredicted) {
double predictedData=generalizedLinearModel.predict(vector);
predictions.add(predictedData);
log.info("String_Node_Str" + predictedData);
}
return predictions;
}
 else if (MLConstants.CLUSTERING.equals((algorithmType))) {
UNSUPERVISED_ALGORITHM unsupervised_algorithm=UNSUPERVISED_ALGORITHM.valueOf(model.getAlgorithmName());
switch (unsupervised_algorithm) {
case K_MEANS:
List<Integer> predictions=new ArrayList<Integer>();
KMeansModel kMeansModel=(KMeansModel)model.getModel();
for (Vector vector : dataToBePredicted) {
int predictedData=kMeansModel.predict(vector);
predictions.add(predictedData);
log.info("String_Node_Str" + predictedData);
}
return predictions;
default :
throw new AlgorithmNameException("String_Node_Str" + model.getAlgorithmName() + "String_Node_Str"+ id);
}
}
 else {
throw new MLModelBuilderException(String.format("String_Node_Str",id,algorithmType));
}
}