Program: 32006
Project: 32006
Buggy source:
/** 
 * Check the setting for model training. It will make sure (num_of_layers > 0 && num_of_layers = hidden_nodes_size && num_of_layse = active_func_size)
 * @param train - @ModelTrainConf to check
 * @return @ValidateResult
 */
@SuppressWarnings("String_Node_Str") private ValidateResult checkTrainSetting(ModelConfig modelConfig,ModelTrainConf train){
  ValidateResult result=new ValidateResult(true);
  if (train.getBaggingNum() == null || train.getBaggingNum() < 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getBaggingSampleRate() == null || train.getBaggingSampleRate().compareTo(Double.valueOf(0)) <= 0 || train.getBaggingSampleRate().compareTo(Double.valueOf(1)) > 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getValidSetRate() == null || train.getValidSetRate().compareTo(Double.valueOf(0)) < 0 || train.getValidSetRate().compareTo(Double.valueOf(1)) >= 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getNumTrainEpochs() == null || train.getNumTrainEpochs() <= 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getEpochsPerIteration() != null && train.getEpochsPerIteration() <= 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getWorkerThreadCount() != null && (train.getWorkerThreadCount() <= 0 || train.getWorkerThreadCount() > 32)) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getConvergenceThreshold() != null && train.getConvergenceThreshold().compareTo(0.0) < 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (modelConfig.isClassification() && train.isOneVsAll() && !CommonUtils.isDesicionTreeAlgorithm(train.getAlgorithm())&& !train.getAlgorithm().equalsIgnoreCase("String_Node_Str")) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (modelConfig.isClassification() && train.getMultiClassifyMethod() == MultipleClassification.NATIVE && train.getAlgorithm().equalsIgnoreCase(CommonConstants.RF_ALG_NAME)) {
    Object impurity=train.getParams().get("String_Node_Str");
    if (impurity != null && !"String_Node_Str".equalsIgnoreCase(impurity.toString()) && !"String_Node_Str".equalsIgnoreCase(impurity.toString())) {
      ValidateResult tmpResult=new ValidateResult(true);
      tmpResult.setStatus(false);
      tmpResult.getCauses().add("String_Node_Str");
      result=ValidateResult.mergeResult(result,tmpResult);
    }
  }
  GridSearch gs=new GridSearch(train.getParams());
  if (modelConfig.isRegression() && !gs.hasHyperParam()) {
    if (train.getAlgorithm().equalsIgnoreCase("String_Node_Str")) {
      Map<String,Object> params=train.getParams();
      int layerCnt=(Integer)params.get(NNTrainer.NUM_HIDDEN_LAYERS);
      if (layerCnt < 0) {
        ValidateResult tmpResult=new ValidateResult(true);
        tmpResult.setStatus(false);
        tmpResult.getCauses().add("String_Node_Str");
        result=ValidateResult.mergeResult(result,tmpResult);
      }
      List<Integer> hiddenNode=(List<Integer>)params.get(NNTrainer.NUM_HIDDEN_NODES);
      List<String> activateFucs=(List<String>)params.get(NNTrainer.ACTIVATION_FUNC);
      if (hiddenNode.size() != activateFucs.size() || layerCnt != activateFucs.size()) {
        ValidateResult tmpResult=new ValidateResult(true);
        tmpResult.setStatus(false);
        tmpResult.getCauses().add(NNTrainer.NUM_HIDDEN_LAYERS + "String_Node_Str" + NNTrainer.NUM_HIDDEN_NODES+ "String_Node_Str"+ "String_Node_Str"+ NNTrainer.ACTIVATION_FUNC+ "String_Node_Str"+ "String_Node_Str");
        result=ValidateResult.mergeResult(result,tmpResult);
      }
      Double learningRate=Double.valueOf(params.get(NNTrainer.LEARNING_RATE).toString());
      if (learningRate != null && (learningRate.compareTo(Double.valueOf(0)) <= 0)) {
        ValidateResult tmpResult=new ValidateResult(true);
        tmpResult.setStatus(false);
        tmpResult.getCauses().add("String_Node_Str");
        result=ValidateResult.mergeResult(result,tmpResult);
      }
      Object learningDecayO=params.get("String_Node_Str");
      if (learningDecayO != null) {
        Double learningDecay=Double.valueOf(learningDecayO.toString());
        if (learningDecay != null && ((learningDecay.compareTo(Double.valueOf(0)) < 0) || (learningDecay.compareTo(Double.valueOf(1)) >= 0))) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
    }
    if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.GBT_ALG_NAME) || train.getAlgorithm().equalsIgnoreCase(CommonConstants.RF_ALG_NAME)) {
      Map<String,Object> params=train.getParams();
      if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.GBT_ALG_NAME)) {
        Object loss=params.get("String_Node_Str");
        if (loss != null && !"String_Node_Str".equalsIgnoreCase(loss.toString()) && !"String_Node_Str".equalsIgnoreCase(loss.toString()) && !"String_Node_Str".equalsIgnoreCase(loss.toString())) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object maxDepthObj=params.get("String_Node_Str");
      if (maxDepthObj != null) {
        int maxDepth=Integer.valueOf(maxDepthObj.toString());
        if (maxDepth <= 0 || maxDepth > 20) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object maxStatsMemoryMBObj=params.get("String_Node_Str");
      if (maxStatsMemoryMBObj != null) {
        int maxStatsMemoryMB=Integer.valueOf(maxStatsMemoryMBObj.toString());
        if (maxStatsMemoryMB <= 0) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.GBT_ALG_NAME)) {
        Object learningRateObj=params.get(NNTrainer.LEARNING_RATE);
        if (learningRateObj != null) {
          Double learningRate=Double.valueOf(learningRateObj.toString());
          if (learningRate != null && (learningRate.compareTo(Double.valueOf(0)) <= 0)) {
            ValidateResult tmpResult=new ValidateResult(true);
            tmpResult.setStatus(false);
            tmpResult.getCauses().add("String_Node_Str");
            result=ValidateResult.mergeResult(result,tmpResult);
          }
        }
      }
      Object minInstancesPerNodeObj=params.get("String_Node_Str");
      if (minInstancesPerNodeObj != null) {
        int minInstancesPerNode=Integer.valueOf(minInstancesPerNodeObj.toString());
        if (minInstancesPerNode <= 0) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object treeNumObj=params.get("String_Node_Str");
      if (treeNumObj != null) {
        int treeNum=Integer.valueOf(treeNumObj.toString());
        if (treeNum <= 0 || treeNum > 2000) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object minInfoGainObj=params.get("String_Node_Str");
      if (minInfoGainObj != null) {
        Double minInfoGain=Double.valueOf(minInfoGainObj.toString());
        if (minInfoGain != null && (minInfoGain.compareTo(Double.valueOf(0)) < 0)) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object impurityObj=params.get("String_Node_Str");
      if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.GBT_ALG_NAME)) {
        if (impurityObj != null && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString()) && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString())) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.RF_ALG_NAME)) {
        if (impurityObj != null && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString()) && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString()) && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString()) && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString())) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Check the setting for model training. It will make sure (num_of_layers > 0 && num_of_layers = hidden_nodes_size && num_of_layse = active_func_size)
 * @param train - @ModelTrainConf to check
 * @return @ValidateResult
 */
@SuppressWarnings("String_Node_Str") private ValidateResult checkTrainSetting(ModelConfig modelConfig,ModelTrainConf train){
  ValidateResult result=new ValidateResult(true);
  if (train.getBaggingNum() == null || train.getBaggingNum() < 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getBaggingSampleRate() == null || train.getBaggingSampleRate().compareTo(Double.valueOf(0)) <= 0 || train.getBaggingSampleRate().compareTo(Double.valueOf(1)) > 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getValidSetRate() == null || train.getValidSetRate().compareTo(Double.valueOf(0)) < 0 || train.getValidSetRate().compareTo(Double.valueOf(1)) >= 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getNumTrainEpochs() == null || train.getNumTrainEpochs() <= 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getEpochsPerIteration() != null && train.getEpochsPerIteration() <= 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getWorkerThreadCount() != null && (train.getWorkerThreadCount() <= 0 || train.getWorkerThreadCount() > 32)) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (train.getConvergenceThreshold() != null && train.getConvergenceThreshold().compareTo(0.0) < 0) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (modelConfig.isClassification() && train.isOneVsAll() && !CommonUtils.isDesicionTreeAlgorithm(train.getAlgorithm())&& !train.getAlgorithm().equalsIgnoreCase("String_Node_Str")) {
    ValidateResult tmpResult=new ValidateResult(true);
    tmpResult.setStatus(false);
    tmpResult.getCauses().add("String_Node_Str");
    result=ValidateResult.mergeResult(result,tmpResult);
  }
  if (modelConfig.isClassification() && train.getMultiClassifyMethod() == MultipleClassification.NATIVE && train.getAlgorithm().equalsIgnoreCase(CommonConstants.RF_ALG_NAME)) {
    Object impurity=train.getParams().get("String_Node_Str");
    if (impurity != null && !"String_Node_Str".equalsIgnoreCase(impurity.toString()) && !"String_Node_Str".equalsIgnoreCase(impurity.toString())) {
      ValidateResult tmpResult=new ValidateResult(true);
      tmpResult.setStatus(false);
      tmpResult.getCauses().add("String_Node_Str");
      result=ValidateResult.mergeResult(result,tmpResult);
    }
  }
  GridSearch gs=new GridSearch(train.getParams());
  if (modelConfig.isRegression() && !gs.hasHyperParam()) {
    if (train.getAlgorithm().equalsIgnoreCase("String_Node_Str")) {
      Map<String,Object> params=train.getParams();
      int layerCnt=(Integer)params.get(NNTrainer.NUM_HIDDEN_LAYERS);
      if (layerCnt < 0) {
        ValidateResult tmpResult=new ValidateResult(true);
        tmpResult.setStatus(false);
        tmpResult.getCauses().add("String_Node_Str");
        result=ValidateResult.mergeResult(result,tmpResult);
      }
      List<Integer> hiddenNode=(List<Integer>)params.get(NNTrainer.NUM_HIDDEN_NODES);
      List<String> activateFucs=(List<String>)params.get(NNTrainer.ACTIVATION_FUNC);
      if (hiddenNode.size() != activateFucs.size() || layerCnt != activateFucs.size()) {
        ValidateResult tmpResult=new ValidateResult(true);
        tmpResult.setStatus(false);
        tmpResult.getCauses().add(NNTrainer.NUM_HIDDEN_LAYERS + "String_Node_Str" + NNTrainer.NUM_HIDDEN_NODES+ "String_Node_Str"+ "String_Node_Str"+ NNTrainer.ACTIVATION_FUNC+ "String_Node_Str"+ "String_Node_Str");
        result=ValidateResult.mergeResult(result,tmpResult);
      }
      Double learningRate=Double.valueOf(params.get(NNTrainer.LEARNING_RATE).toString());
      if (learningRate != null && (learningRate.compareTo(Double.valueOf(0)) <= 0)) {
        ValidateResult tmpResult=new ValidateResult(true);
        tmpResult.setStatus(false);
        tmpResult.getCauses().add("String_Node_Str");
        result=ValidateResult.mergeResult(result,tmpResult);
      }
      Object learningDecayO=params.get("String_Node_Str");
      if (learningDecayO != null) {
        Double learningDecay=Double.valueOf(learningDecayO.toString());
        if (learningDecay != null && ((learningDecay.compareTo(Double.valueOf(0)) < 0) || (learningDecay.compareTo(Double.valueOf(1)) >= 0))) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
    }
    if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.GBT_ALG_NAME) || train.getAlgorithm().equalsIgnoreCase(CommonConstants.RF_ALG_NAME)) {
      Map<String,Object> params=train.getParams();
      if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.GBT_ALG_NAME)) {
        Object loss=params.get("String_Node_Str");
        if (loss != null && !"String_Node_Str".equalsIgnoreCase(loss.toString()) && !"String_Node_Str".equalsIgnoreCase(loss.toString()) && !"String_Node_Str".equalsIgnoreCase(loss.toString()) && !"String_Node_Str".equalsIgnoreCase(loss.toString())) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object maxDepthObj=params.get("String_Node_Str");
      if (maxDepthObj != null) {
        int maxDepth=Integer.valueOf(maxDepthObj.toString());
        if (maxDepth <= 0 || maxDepth > 20) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object maxStatsMemoryMBObj=params.get("String_Node_Str");
      if (maxStatsMemoryMBObj != null) {
        int maxStatsMemoryMB=Integer.valueOf(maxStatsMemoryMBObj.toString());
        if (maxStatsMemoryMB <= 0) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.GBT_ALG_NAME)) {
        Object learningRateObj=params.get(NNTrainer.LEARNING_RATE);
        if (learningRateObj != null) {
          Double learningRate=Double.valueOf(learningRateObj.toString());
          if (learningRate != null && (learningRate.compareTo(Double.valueOf(0)) <= 0)) {
            ValidateResult tmpResult=new ValidateResult(true);
            tmpResult.setStatus(false);
            tmpResult.getCauses().add("String_Node_Str");
            result=ValidateResult.mergeResult(result,tmpResult);
          }
        }
      }
      Object minInstancesPerNodeObj=params.get("String_Node_Str");
      if (minInstancesPerNodeObj != null) {
        int minInstancesPerNode=Integer.valueOf(minInstancesPerNodeObj.toString());
        if (minInstancesPerNode <= 0) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object treeNumObj=params.get("String_Node_Str");
      if (treeNumObj != null) {
        int treeNum=Integer.valueOf(treeNumObj.toString());
        if (treeNum <= 0 || treeNum > 2000) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object minInfoGainObj=params.get("String_Node_Str");
      if (minInfoGainObj != null) {
        Double minInfoGain=Double.valueOf(minInfoGainObj.toString());
        if (minInfoGain != null && (minInfoGain.compareTo(Double.valueOf(0)) < 0)) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      Object impurityObj=params.get("String_Node_Str");
      if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.GBT_ALG_NAME)) {
        if (impurityObj != null && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString()) && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString())) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
      if (train.getAlgorithm().equalsIgnoreCase(CommonConstants.RF_ALG_NAME)) {
        if (impurityObj != null && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString()) && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString()) && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString()) && !"String_Node_Str".equalsIgnoreCase(impurityObj.toString())) {
          ValidateResult tmpResult=new ValidateResult(true);
          tmpResult.setStatus(false);
          tmpResult.getCauses().add("String_Node_Str");
          result=ValidateResult.mergeResult(result,tmpResult);
        }
      }
    }
  }
  return result;
}