Program: 144086
Project: 144086
Buggy source:
@SuppressWarnings("String_Node_Str") public static void main(String[] args){
  Integrator.CoTrainingMethod coTrainingMethod;
  String workingDirectory;
switch (args[0]) {
case "String_Node_Str":
    coTrainingMethod=Integrator.CoTrainingMethod.CO_TRAINING;
  workingDirectory=integratorWorkingDirectory + "String_Node_Str";
break;
case "String_Node_Str":
coTrainingMethod=Integrator.CoTrainingMethod.ROBUST_CO_TRAINING;
workingDirectory=integratorWorkingDirectory + "String_Node_Str";
break;
case "String_Node_Str":
coTrainingMethod=Integrator.CoTrainingMethod.ROBUST_CO_TRAINING_GM;
workingDirectory=integratorWorkingDirectory + "String_Node_Str";
break;
default :
coTrainingMethod=Integrator.CoTrainingMethod.CO_TRAINING;
workingDirectory=integratorWorkingDirectory + "String_Node_Str";
}
initializeWorkingDirectory(workingDirectory);
loadLabeledNPsData();
double[] weightedMajorityAccuracy=new double[numberOfIterations];
double[][] actualErrorRates=new double[numberOfIterations][numberOfViews];
double[][] precision=new double[numberOfIterations][numberOfViews];
double[][] recall=new double[numberOfIterations][numberOfViews];
double[][] f1Score=new double[numberOfIterations][numberOfViews];
double[][] estimatedErrorRates=new double[numberOfIterations][numberOfViews];
Integrator.Builder<Vector,Double> integratorBuilder=new Integrator.Builder<Vector,Double>(integratorWorkingDirectory).labeledDataSet(labeledDataSet).unlabeledDataSet(unlabeledDataSet).completedIterationEventHandlers((completedIterationEvent,sequence,endOfBatch) -> {
int iterationNumber=((Integrator.CompletedIterationEvent)completedIterationEvent).getIterationNumber();
List<TrainableClassifier<Vector,Double>> classifiers=((Integrator.CompletedIterationEvent)completedIterationEvent).getClassifiers();
estimatedErrorRates[iterationNumber]=((Integrator.CompletedIterationEvent)completedIterationEvent).getErrorRates();
for (int view=0; view < numberOfViews; view++) {
DataSet<PredictedDataInstance<Vector,Double>> predictedEvaluationDataSet=classifiers.get(view).predict((DataSet<PredictedDataInstance<Vector,Double>>)evaluationDataSet.getSingleViewDataSet(view));
double precisionDenominator=0;
double recallDenominator=0;
for (PredictedDataInstance<Vector,Double> dataInstance : predictedEvaluationDataSet) {
if (dataInstance.label() != (filteredLabeledData.get(category).get(dataInstance.name()) ? 1 : 0)) actualErrorRates[iterationNumber][view]++;
if (dataInstance.label() == 1) {
precisionDenominator++;
if (filteredLabeledData.get(category).get(dataInstance.name())) precision[iterationNumber][view]++;
}
if (filteredLabeledData.get(category).get(dataInstance.name())) {
recallDenominator++;
if (dataInstance.label() == 1) recall[iterationNumber][view]++;
}
}
if (precisionDenominator == 0) precisionDenominator=1;
if (recallDenominator == 0) recallDenominator=1;
actualErrorRates[iterationNumber][view]/=predictedEvaluationDataSet.size();
precision[iterationNumber][view]/=precisionDenominator;
recall[iterationNumber][view]/=recallDenominator;
f1Score[iterationNumber][view]=2 * (precision[iterationNumber][view] * recall[iterationNumber][view]) / (precision[iterationNumber][view] + recall[iterationNumber][view]);
if (precision[iterationNumber][view] == 0 && recall[iterationNumber][view] == 0) f1Score[iterationNumber][view]=0;
logger.info("String_Node_Str" + (iterationNumber + 1) + "String_Node_Str"+ (view + 1)+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(actualErrorRates[iterationNumber][view])+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(estimatedErrorRates[iterationNumber][view])+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(precision[iterationNumber][view])+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(recall[iterationNumber][view])+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(f1Score[iterationNumber][view])+ "String_Node_Str");
}
saveResultsForMATLAB(workingDirectory + "String_Node_Str",actualErrorRates,estimatedErrorRates,precision,recall,f1Score);
}
).coTrainingMethod(Integrator.CoTrainingMethod.ROBUST_CO_TRAINING_GM).dataSelectionMethod(Integrator.DataSelectionMethod.FIXED_PROPORTION).dataSelectionParameter(0.01).numberOfThreads(numberOfViews).saveModelsOnEveryIteration(true).useDifferentFilePerIteration(true);
for (int view=0; view < numberOfViews; view++) {
LogisticRegressionAdaGrad classifier=new LogisticRegressionAdaGrad.Builder(unlabeledDataSet.get(0).getSingleViewDataInstance(view).features().size()).sparse(true).useBiasTerm(true).useL1Regularization(false).l1RegularizationWeight(0.0001).useL2Regularization(false).l2RegularizationWeight(0.1).loggingLevel(0).sampleWithReplacement(true).maximumNumberOfIterations(1000).maximumNumberOfIterationsWithNoPointChange(10).pointChangeTolerance(1e-5).checkForPointConvergence(true).batchSize(10000000).random(random).build();
integratorBuilder.addClassifier(classifier);
}
Integrator<Vector,Double> integrator=integratorBuilder.build();
for (int iteration=integrator.getIterationNumber(); iteration < numberOfIterations; iteration++) integrator.performSingleIteration();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static void main(String[] args){
  Integrator.CoTrainingMethod coTrainingMethod;
  String workingDirectory;
switch (args[0]) {
case "String_Node_Str":
    coTrainingMethod=Integrator.CoTrainingMethod.CO_TRAINING;
  workingDirectory=integratorWorkingDirectory + "String_Node_Str";
break;
case "String_Node_Str":
coTrainingMethod=Integrator.CoTrainingMethod.ROBUST_CO_TRAINING;
workingDirectory=integratorWorkingDirectory + "String_Node_Str";
break;
case "String_Node_Str":
coTrainingMethod=Integrator.CoTrainingMethod.ROBUST_CO_TRAINING_GM;
workingDirectory=integratorWorkingDirectory + "String_Node_Str";
break;
default :
coTrainingMethod=Integrator.CoTrainingMethod.CO_TRAINING;
workingDirectory=integratorWorkingDirectory + "String_Node_Str";
}
initializeWorkingDirectory(workingDirectory);
loadLabeledNPsData();
double[] weightedMajorityAccuracy=new double[numberOfIterations];
double[][] actualErrorRates=new double[numberOfIterations][numberOfViews];
double[][] precision=new double[numberOfIterations][numberOfViews];
double[][] recall=new double[numberOfIterations][numberOfViews];
double[][] f1Score=new double[numberOfIterations][numberOfViews];
double[][] estimatedErrorRates=new double[numberOfIterations][numberOfViews];
Integrator.Builder<Vector,Double> integratorBuilder=new Integrator.Builder<Vector,Double>(integratorWorkingDirectory).labeledDataSet(labeledDataSet).unlabeledDataSet(unlabeledDataSet).completedIterationEventHandlers((completedIterationEvent,sequence,endOfBatch) -> {
int iterationNumber=((Integrator.CompletedIterationEvent)completedIterationEvent).getIterationNumber();
List<TrainableClassifier<Vector,Double>> classifiers=((Integrator.CompletedIterationEvent)completedIterationEvent).getClassifiers();
estimatedErrorRates[iterationNumber]=((Integrator.CompletedIterationEvent)completedIterationEvent).getErrorRates();
for (int view=0; view < numberOfViews; view++) {
DataSet<PredictedDataInstance<Vector,Double>> predictedEvaluationDataSet=classifiers.get(view).predict((DataSet<PredictedDataInstance<Vector,Double>>)evaluationDataSet.getSingleViewDataSet(view));
double precisionDenominator=0;
double recallDenominator=0;
for (PredictedDataInstance<Vector,Double> dataInstance : predictedEvaluationDataSet) {
if (dataInstance.label() != (filteredLabeledData.get(category).get(dataInstance.name()) ? 1 : 0)) actualErrorRates[iterationNumber][view]++;
if (dataInstance.label() == 1) {
precisionDenominator++;
if (filteredLabeledData.get(category).get(dataInstance.name())) precision[iterationNumber][view]++;
}
if (filteredLabeledData.get(category).get(dataInstance.name())) {
recallDenominator++;
if (dataInstance.label() == 1) recall[iterationNumber][view]++;
}
}
if (precisionDenominator == 0) precisionDenominator=1;
if (recallDenominator == 0) recallDenominator=1;
actualErrorRates[iterationNumber][view]/=predictedEvaluationDataSet.size();
precision[iterationNumber][view]/=precisionDenominator;
recall[iterationNumber][view]/=recallDenominator;
f1Score[iterationNumber][view]=2 * (precision[iterationNumber][view] * recall[iterationNumber][view]) / (precision[iterationNumber][view] + recall[iterationNumber][view]);
if (precision[iterationNumber][view] == 0 && recall[iterationNumber][view] == 0) f1Score[iterationNumber][view]=0;
logger.info("String_Node_Str" + (iterationNumber + 1) + "String_Node_Str"+ (view + 1)+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(actualErrorRates[iterationNumber][view])+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(estimatedErrorRates[iterationNumber][view])+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(precision[iterationNumber][view])+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(recall[iterationNumber][view])+ "String_Node_Str"+ "String_Node_Str"+ formatter.format(f1Score[iterationNumber][view])+ "String_Node_Str");
}
saveResultsForMATLAB(workingDirectory + "String_Node_Str",actualErrorRates,estimatedErrorRates,precision,recall,f1Score);
}
).coTrainingMethod(coTrainingMethod).dataSelectionMethod(Integrator.DataSelectionMethod.FIXED_PROPORTION).dataSelectionParameter(0.01).numberOfThreads(numberOfViews).saveModelsOnEveryIteration(true).useDifferentFilePerIteration(true);
for (int view=0; view < numberOfViews; view++) {
LogisticRegressionAdaGrad classifier=new LogisticRegressionAdaGrad.Builder(unlabeledDataSet.get(0).getSingleViewDataInstance(view).features().size()).sparse(true).useBiasTerm(true).useL1Regularization(false).l1RegularizationWeight(0.0001).useL2Regularization(false).l2RegularizationWeight(0.1).loggingLevel(0).sampleWithReplacement(true).maximumNumberOfIterations(1000).maximumNumberOfIterationsWithNoPointChange(10).pointChangeTolerance(1e-5).checkForPointConvergence(true).batchSize(10000000).random(random).build();
integratorBuilder.addClassifier(classifier);
}
Integrator<Vector,Double> integrator=integratorBuilder.build();
for (int iteration=integrator.getIterationNumber(); iteration < numberOfIterations; iteration++) integrator.performSingleIteration();
}