Program: 32930
Project: 32930
Buggy source:
private static void train(Config config) throws Exception {
  String matrixType=config.getString("String_Node_Str");
  MultiLabelClfDataSet trainSet;
  MultiLabelClfDataSet testSet;
switch (matrixType) {
case "String_Node_Str":
    trainSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_SPARSE,true);
  testSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_SPARSE,true);
break;
case "String_Node_Str":
trainSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_SEQ_SPARSE,true);
testSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_SEQ_SPARSE,true);
break;
case "String_Node_Str":
trainSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_DENSE,true);
testSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_DENSE,true);
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
int numIterations=config.getInt("String_Node_Str");
String output=config.getString("String_Node_Str");
String modelName="String_Node_Str";
File path=Paths.get(output,modelName).toFile();
path.mkdirs();
Pair<CBM,Integer> pair=loadCBM(config,trainSet);
CBM cbm=pair.getFirst();
CBMOptimizer optimizer=getOptimizer(config,cbm,trainSet);
PluginF1 pluginF1=new PluginF1(cbm);
List<MultiLabel> support=DataSetUtil.gatherMultiLabels(trainSet);
pluginF1.setSupport(support);
MultiLabelClassifier classifier;
String predictTarget=config.getString("String_Node_Str");
switch (predictTarget) {
case "String_Node_Str":
classifier=cbm;
break;
case "String_Node_Str":
classifier=pluginF1;
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
double gammaLabel=0;
double maxGammaLabel=config.getDouble("String_Node_Str");
double gammaSet=0;
double maxGammaSet=config.getDouble("String_Node_Str");
List<Double> trainAcc=new ArrayList<>();
List<Double> testAcc=new ArrayList<>();
List<Double> trainF1=new ArrayList<>();
List<Double> trainGFMF1=new ArrayList<>();
List<Double> testF1=new ArrayList<>();
List<Double> trainMap=new ArrayList<>();
List<Double> testMap=new ArrayList<>();
List<Double> testGFMF1=new ArrayList<>();
for (int i=1; i <= numIterations; i++) {
System.out.println("String_Node_Str");
System.out.println("String_Node_Str" + i);
System.out.println("String_Node_Str" + gammaLabel);
System.out.println("String_Node_Str" + gammaSet);
optimizer.setNoiseGammaSet(gammaLabel);
optimizer.setNoiseGammaSet(gammaSet);
optimizer.iterate();
System.out.println("String_Node_Str" + optimizer.getTerminator().getLastValue());
System.out.println("String_Node_Str" + predictTarget + "String_Node_Str");
MLMeasures trainMeasures=new MLMeasures(classifier,trainSet);
System.out.println(trainMeasures);
trainAcc.add(trainMeasures.getInstanceAverage().getAccuracy());
trainF1.add(trainMeasures.getInstanceAverage().getF1());
trainGFMF1.add(new MLMeasures(pluginF1,trainSet).getInstanceAverage().getF1());
trainMap.add(MAP.map(cbm,trainSet));
System.out.println("String_Node_Str" + predictTarget + "String_Node_Str");
MLMeasures testMeasures=new MLMeasures(classifier,testSet);
System.out.println(testMeasures);
testAcc.add(testMeasures.getInstanceAverage().getAccuracy());
testF1.add(testMeasures.getInstanceAverage().getF1());
testGFMF1.add(new MLMeasures(pluginF1,testSet).getInstanceAverage().getF1());
testMap.add(MAP.map(cbm,testSet));
File serializeModel=new File(path,"String_Node_Str" + i + "String_Node_Str");
cbm.serialize(serializeModel);
double[][] noiseLabelWeights=optimizer.getNoiseLabelWeights();
StringBuilder stringBuilder=new StringBuilder();
for (int n=0; n < trainSet.getNumDataPoints(); n++) {
stringBuilder.append(PrintUtil.printWithIndex(noiseLabelWeights[n])).append("String_Node_Str");
}
File weightFile=Paths.get(output,"String_Node_Str","String_Node_Str" + i).toFile();
FileUtils.writeStringToFile(weightFile,stringBuilder.toString());
double[] noiseSetWeights=optimizer.getNoiseSetWeights();
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str" + i).toFile(),PrintUtil.toMutipleLines(noiseSetWeights));
gammaLabel+=config.getDouble("String_Node_Str");
if (gammaLabel > maxGammaLabel) {
gammaLabel=maxGammaLabel;
}
gammaSet+=config.getDouble("String_Node_Str");
if (gammaSet > maxGammaSet) {
gammaSet=maxGammaSet;
}
}
System.out.println("String_Node_Str");
File serializeModel=new File(path,"String_Node_Str");
cbm.serialize(serializeModel);
Serialization.serialize(support,Paths.get(output,"String_Node_Str","String_Node_Str").toFile());
System.out.println();
System.out.println("String_Node_Str");
System.out.println("String_Node_Str" + predictTarget + "String_Node_Str");
System.out.println(new MLMeasures(classifier,trainSet));
report(config,cbm,classifier,trainSet,"String_Node_Str");
System.out.println("String_Node_Str");
System.out.println();
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(trainAcc));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(trainF1));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(trainGFMF1));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(trainMap));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(testAcc));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(testF1));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(testGFMF1));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(testMap));
}

Fixed version (ground truth):
private static void train(Config config) throws Exception {
  String matrixType=config.getString("String_Node_Str");
  MultiLabelClfDataSet trainSet;
  MultiLabelClfDataSet testSet;
switch (matrixType) {
case "String_Node_Str":
    trainSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_SPARSE,true);
  testSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_SPARSE,true);
break;
case "String_Node_Str":
trainSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_SEQ_SPARSE,true);
testSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_SEQ_SPARSE,true);
break;
case "String_Node_Str":
trainSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_DENSE,true);
testSet=TRECFormat.loadMultiLabelClfDataSet(config.getString("String_Node_Str"),DataSetType.ML_CLF_DENSE,true);
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
int numIterations=config.getInt("String_Node_Str");
String output=config.getString("String_Node_Str");
String modelName="String_Node_Str";
File path=Paths.get(output,modelName).toFile();
path.mkdirs();
Pair<CBM,Integer> pair=loadCBM(config,trainSet);
CBM cbm=pair.getFirst();
CBMOptimizer optimizer=getOptimizer(config,cbm,trainSet);
PluginF1 pluginF1=new PluginF1(cbm);
List<MultiLabel> support=DataSetUtil.gatherMultiLabels(trainSet);
pluginF1.setSupport(support);
MultiLabelClassifier classifier;
String predictTarget=config.getString("String_Node_Str");
switch (predictTarget) {
case "String_Node_Str":
classifier=cbm;
break;
case "String_Node_Str":
classifier=pluginF1;
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
double gammaLabel=0;
double maxGammaLabel=config.getDouble("String_Node_Str");
double gammaSet=0;
double maxGammaSet=config.getDouble("String_Node_Str");
List<Double> trainAcc=new ArrayList<>();
List<Double> testAcc=new ArrayList<>();
List<Double> trainF1=new ArrayList<>();
List<Double> trainGFMF1=new ArrayList<>();
List<Double> testF1=new ArrayList<>();
List<Double> trainMap=new ArrayList<>();
List<Double> testMap=new ArrayList<>();
List<Double> testGFMF1=new ArrayList<>();
for (int i=1; i <= numIterations; i++) {
System.out.println("String_Node_Str");
System.out.println("String_Node_Str" + i);
System.out.println("String_Node_Str" + gammaLabel);
System.out.println("String_Node_Str" + gammaSet);
optimizer.setNoiseGammaLabel(gammaLabel);
optimizer.setNoiseGammaSet(gammaSet);
optimizer.iterate();
System.out.println("String_Node_Str" + optimizer.getTerminator().getLastValue());
System.out.println("String_Node_Str" + predictTarget + "String_Node_Str");
MLMeasures trainMeasures=new MLMeasures(classifier,trainSet);
System.out.println(trainMeasures);
trainAcc.add(trainMeasures.getInstanceAverage().getAccuracy());
trainF1.add(trainMeasures.getInstanceAverage().getF1());
trainGFMF1.add(new MLMeasures(pluginF1,trainSet).getInstanceAverage().getF1());
trainMap.add(MAP.map(cbm,trainSet));
System.out.println("String_Node_Str" + predictTarget + "String_Node_Str");
MLMeasures testMeasures=new MLMeasures(classifier,testSet);
System.out.println(testMeasures);
testAcc.add(testMeasures.getInstanceAverage().getAccuracy());
testF1.add(testMeasures.getInstanceAverage().getF1());
testGFMF1.add(new MLMeasures(pluginF1,testSet).getInstanceAverage().getF1());
testMap.add(MAP.map(cbm,testSet));
File serializeModel=new File(path,"String_Node_Str" + i + "String_Node_Str");
cbm.serialize(serializeModel);
double[][] noiseLabelWeights=optimizer.getNoiseLabelWeights();
StringBuilder stringBuilder=new StringBuilder();
for (int n=0; n < trainSet.getNumDataPoints(); n++) {
stringBuilder.append(PrintUtil.printWithIndex(noiseLabelWeights[n])).append("String_Node_Str");
}
File weightFile=Paths.get(output,"String_Node_Str","String_Node_Str" + i).toFile();
FileUtils.writeStringToFile(weightFile,stringBuilder.toString());
double[] noiseSetWeights=optimizer.getNoiseSetWeights();
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str" + i).toFile(),PrintUtil.toMutipleLines(noiseSetWeights));
gammaLabel+=config.getDouble("String_Node_Str");
if (gammaLabel > maxGammaLabel) {
gammaLabel=maxGammaLabel;
}
gammaSet+=config.getDouble("String_Node_Str");
if (gammaSet > maxGammaSet) {
gammaSet=maxGammaSet;
}
}
System.out.println("String_Node_Str");
File serializeModel=new File(path,"String_Node_Str");
cbm.serialize(serializeModel);
Serialization.serialize(support,Paths.get(output,"String_Node_Str","String_Node_Str").toFile());
System.out.println();
System.out.println("String_Node_Str");
System.out.println("String_Node_Str" + predictTarget + "String_Node_Str");
System.out.println(new MLMeasures(classifier,trainSet));
report(config,cbm,classifier,trainSet,"String_Node_Str");
System.out.println("String_Node_Str");
System.out.println();
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(trainAcc));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(trainF1));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(trainGFMF1));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(trainMap));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(testAcc));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(testF1));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(testGFMF1));
FileUtils.writeStringToFile(Paths.get(output,"String_Node_Str","String_Node_Str").toFile(),ListUtil.toSimpleString(testMap));
}