Program: 32912
Project: 32912
Buggy source:
static void reportCalibrated(Config config,String dataName,Logger logger) throws Exception {
  logger.info("String_Node_Str" + dataName);
  String output=config.getString("String_Node_Str");
  String modelName="String_Node_Str";
  String setCalibration="String_Node_Str";
  String labelCalibration="String_Node_Str";
  File analysisFolder=new File(new File(output,"String_Node_Str"),dataName + "String_Node_Str");
  analysisFolder.mkdirs();
  FileUtils.cleanDirectory(analysisFolder);
  IMLGradientBoosting boosting=IMLGradientBoosting.deserialize(new File(output,modelName));
  IMLGBIsotonicScaling setScaling=(IMLGBIsotonicScaling)Serialization.deserialize(new File(output,setCalibration));
  IMLGBLabelIsotonicScaling labelScaling=(IMLGBLabelIsotonicScaling)Serialization.deserialize(new File(output,labelCalibration));
  String predictTarget=config.getString("String_Node_Str");
  PluginPredictor<IMLGradientBoosting> pluginPredictorTmp=null;
switch (predictTarget) {
case "String_Node_Str":
    pluginPredictorTmp=new SubsetAccPredictor(boosting);
  break;
case "String_Node_Str":
pluginPredictorTmp=new HammingPredictor(boosting);
break;
case "String_Node_Str":
pluginPredictorTmp=new InstanceF1Predictor(boosting);
break;
case "String_Node_Str":
TunedMarginalClassifier tunedMarginalClassifier=(TunedMarginalClassifier)Serialization.deserialize(new File(output,"String_Node_Str"));
pluginPredictorTmp=new MacroF1Predictor(boosting,tunedMarginalClassifier);
break;
default :
throw new IllegalArgumentException("String_Node_Str" + predictTarget);
}
final PluginPredictor<IMLGradientBoosting> pluginPredictor=pluginPredictorTmp;
MultiLabelClfDataSet dataSet=loadData(config,dataName);
logger.info("String_Node_Str");
double[] all=IntStream.range(0,dataSet.getNumDataPoints()).mapToDouble(dataPointIndex -> Arrays.stream(boosting.predictAllAssignmentProbsWithConstraint(dataSet.getRow(dataPointIndex))).map(setScaling::calibratedProb).sum()).toArray();
DescriptiveStatistics descriptiveStatistics=new DescriptiveStatistics(all);
logger.info(descriptiveStatistics.toString());
MLMeasures mlMeasures=new MLMeasures(pluginPredictor,dataSet);
mlMeasures.getMacroAverage().setLabelTranslator(dataSet.getLabelTranslator());
logger.info("String_Node_Str" + dataName);
logger.info(mlMeasures.toString());
List<Integer> reportIdOrderTmp=IntStream.range(0,dataSet.getNumDataPoints()).boxed().collect(Collectors.toList());
if (config.getString("String_Node_Str").equals("String_Node_Str")) {
Comparator<Pair<Integer,Double>> confidenceComparator=Comparator.comparing(pair -> pair.getSecond());
reportIdOrderTmp=IntStream.range(0,dataSet.getNumDataPoints()).parallel().mapToObj(i -> {
MultiLabel prediction=pluginPredictor.predict(dataSet.getRow(i));
double confidence=setScaling.calibratedProb(dataSet.getRow(i),prediction);
return new Pair<>(i,confidence);
}
).sorted(confidenceComparator.reversed()).map(Pair::getFirst).collect(Collectors.toList());
}
if (config.getString("String_Node_Str").equals("String_Node_Str")) {
Comparator<Pair<Integer,Double>> mistakeComparator=Comparator.comparing(pair -> pair.getSecond());
reportIdOrderTmp=IntStream.range(0,dataSet.getNumDataPoints()).parallel().mapToObj(i -> {
MultiLabel prediction=pluginPredictor.predict(dataSet.getRow(i));
double confidence=setScaling.calibratedProb(dataSet.getRow(i),prediction);
double instanceF1=FMeasure.f1(prediction,dataSet.getMultiLabels()[i]);
return new Pair<>(i,(1 - instanceF1) * confidence);
}
).sorted(mistakeComparator.reversed()).map(Pair::getFirst).collect(Collectors.toList());
}
final List<Integer> reportIdOrder=reportIdOrderTmp;
boolean simpleCSV=true;
if (simpleCSV) {
logger.info("String_Node_Str");
double probThreshold=config.getDouble("String_Node_Str");
File csv=new File(analysisFolder,"String_Node_Str");
List<String> strs=reportIdOrder.stream().parallel().map(i -> IMLGBInspector.simplePredictionAnalysisCalibrated(boosting,setScaling,labelScaling,pluginPredictor,dataSet,i,probThreshold)).collect(Collectors.toList());
try (BufferedWriter bw=new BufferedWriter(new FileWriter(csv))){
for (int i : reportIdOrder) {
String str=strs.get(i);
bw.write(str);
}
}
 logger.info("String_Node_Str");
}
boolean rulesToJson=config.getBoolean("String_Node_Str");
if (rulesToJson) {
logger.info("String_Node_Str");
int ruleLimit=config.getInt("String_Node_Str");
int numDocsPerFile=config.getInt("String_Node_Str");
int numFiles=(int)Math.ceil((double)dataSet.getNumDataPoints() / numDocsPerFile);
double probThreshold=config.getDouble("String_Node_Str");
int labelSetLimit=config.getInt("String_Node_Str");
IntStream.range(0,numFiles).forEach(i -> {
int start=i * numDocsPerFile;
int end=start + numDocsPerFile;
List<MultiLabelPredictionAnalysis> partition=IntStream.range(start,Math.min(end,dataSet.getNumDataPoints())).parallel().mapToObj(a -> IMLGBInspector.analyzePredictionCalibrated(boosting,setScaling,labelScaling,pluginPredictor,dataSet,reportIdOrder.get(a),ruleLimit,labelSetLimit,probThreshold)).collect(Collectors.toList());
ObjectMapper mapper=new ObjectMapper();
String file="String_Node_Str" + (i + 1) + "String_Node_Str";
try {
mapper.writeValue(new File(analysisFolder,file),partition);
}
 catch (IOException e) {
e.printStackTrace();
}
logger.info("String_Node_Str" + Progress.percentage(i + 1,numFiles));
}
);
logger.info("String_Node_Str");
}
boolean dataInfoToJson=true;
if (dataInfoToJson) {
logger.info("String_Node_Str");
Set<String> modelLabels=IntStream.range(0,boosting.getNumClasses()).mapToObj(i -> boosting.getLabelTranslator().toExtLabel(i)).collect(Collectors.toSet());
Set<String> dataSetLabels=DataSetUtil.gatherLabels(dataSet).stream().map(i -> dataSet.getLabelTranslator().toExtLabel(i)).collect(Collectors.toSet());
JsonGenerator jsonGenerator=new JsonFactory().createGenerator(new File(analysisFolder,"String_Node_Str"),JsonEncoding.UTF8);
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("String_Node_Str",dataName);
jsonGenerator.writeNumberField("String_Node_Str",boosting.getNumClasses());
jsonGenerator.writeNumberField("String_Node_Str",dataSetLabels.size());
jsonGenerator.writeNumberField("String_Node_Str",dataSet.getNumClasses());
Set<String> modelNotDataLabels=SetUtil.complement(modelLabels,dataSetLabels);
Set<String> dataNotModelLabels=SetUtil.complement(dataSetLabels,modelLabels);
jsonGenerator.writeNumberField("String_Node_Str",dataNotModelLabels.size());
jsonGenerator.writeNumberField("String_Node_Str",modelNotDataLabels.size());
jsonGenerator.writeArrayFieldStart("String_Node_Str");
for (String label : dataNotModelLabels) {
jsonGenerator.writeObject(label);
}
jsonGenerator.writeEndArray();
jsonGenerator.writeArrayFieldStart("String_Node_Str");
for (String label : modelNotDataLabels) {
jsonGenerator.writeObject(label);
}
jsonGenerator.writeEndArray();
jsonGenerator.writeNumberField("String_Node_Str",dataSet.labelCardinality());
jsonGenerator.writeEndObject();
jsonGenerator.close();
logger.info("String_Node_Str");
}
boolean modelConfigToJson=true;
if (modelConfigToJson) {
logger.info("String_Node_Str");
ObjectMapper objectMapper=new ObjectMapper();
objectMapper.writeValue(new File(analysisFolder,"String_Node_Str"),config);
logger.info("String_Node_Str");
}
boolean dataConfigToJson=true;
if (dataConfigToJson) {
logger.info("String_Node_Str");
File dataConfigFile=Paths.get(config.getString("String_Node_Str"),"String_Node_Str",dataName,"String_Node_Str").toFile();
if (dataConfigFile.exists()) {
FileUtils.copyFileToDirectory(dataConfigFile,analysisFolder);
}
logger.info("String_Node_Str");
}
boolean performanceToJson=true;
if (performanceToJson) {
ObjectMapper objectMapper=new ObjectMapper();
objectMapper.writeValue(new File(analysisFolder,"String_Node_Str"),mlMeasures);
}
boolean individualPerformance=true;
if (individualPerformance) {
logger.info("String_Node_Str");
ObjectMapper objectMapper=new ObjectMapper();
objectMapper.writeValue(new File(analysisFolder,"String_Node_Str"),mlMeasures.getMacroAverage());
logger.info("String_Node_Str");
}
if (config.getBoolean("String_Node_Str")) {
logger.info("String_Node_Str");
Config savedApp1Config=new Config(Paths.get(config.getString("String_Node_Str"),"String_Node_Str","String_Node_Str").toFile());
List<String> hosts=savedApp1Config.getStrings("String_Node_Str");
List<Integer> ports=savedApp1Config.getIntegers("String_Node_Str");
if (savedApp1Config.getString("String_Node_Str").equals("String_Node_Str")) {
hosts=new ArrayList<>();
for (int port : ports) {
hosts.add("String_Node_Str");
}
hosts.add("String_Node_Str");
ports.add(9200);
}
try (Visualizer visualizer=new Visualizer(logger,hosts,ports)){
visualizer.produceHtml(analysisFolder);
logger.info("String_Node_Str");
}
 }
logger.info("String_Node_Str");
}

Fixed version (ground truth):
static void reportCalibrated(Config config,String dataName,Logger logger) throws Exception {
  logger.info("String_Node_Str" + dataName);
  String output=config.getString("String_Node_Str");
  String modelName="String_Node_Str";
  String setCalibration="String_Node_Str";
  String labelCalibration="String_Node_Str";
  File analysisFolder=new File(new File(output,"String_Node_Str"),dataName + "String_Node_Str");
  analysisFolder.mkdirs();
  FileUtils.cleanDirectory(analysisFolder);
  IMLGradientBoosting boosting=IMLGradientBoosting.deserialize(new File(output,modelName));
  IMLGBIsotonicScaling setScaling=(IMLGBIsotonicScaling)Serialization.deserialize(new File(output,setCalibration));
  IMLGBLabelIsotonicScaling labelScaling=(IMLGBLabelIsotonicScaling)Serialization.deserialize(new File(output,labelCalibration));
  String predictTarget=config.getString("String_Node_Str");
  PluginPredictor<IMLGradientBoosting> pluginPredictorTmp=null;
switch (predictTarget) {
case "String_Node_Str":
    pluginPredictorTmp=new SubsetAccPredictor(boosting);
  break;
case "String_Node_Str":
pluginPredictorTmp=new HammingPredictor(boosting);
break;
case "String_Node_Str":
pluginPredictorTmp=new InstanceF1Predictor(boosting);
break;
case "String_Node_Str":
TunedMarginalClassifier tunedMarginalClassifier=(TunedMarginalClassifier)Serialization.deserialize(new File(output,"String_Node_Str"));
pluginPredictorTmp=new MacroF1Predictor(boosting,tunedMarginalClassifier);
break;
default :
throw new IllegalArgumentException("String_Node_Str" + predictTarget);
}
final PluginPredictor<IMLGradientBoosting> pluginPredictor=pluginPredictorTmp;
MultiLabelClfDataSet dataSet=loadData(config,dataName);
logger.info("String_Node_Str");
double[] all=IntStream.range(0,dataSet.getNumDataPoints()).mapToDouble(dataPointIndex -> Arrays.stream(boosting.predictAllAssignmentProbsWithConstraint(dataSet.getRow(dataPointIndex))).map(setScaling::calibratedProb).sum()).toArray();
DescriptiveStatistics descriptiveStatistics=new DescriptiveStatistics(all);
logger.info(descriptiveStatistics.toString());
MLMeasures mlMeasures=new MLMeasures(pluginPredictor,dataSet);
mlMeasures.getMacroAverage().setLabelTranslator(dataSet.getLabelTranslator());
logger.info("String_Node_Str" + dataName);
logger.info(mlMeasures.toString());
List<Integer> reportIdOrderTmp=IntStream.range(0,dataSet.getNumDataPoints()).boxed().collect(Collectors.toList());
if (config.getString("String_Node_Str").equals("String_Node_Str")) {
Comparator<Pair<Integer,Double>> confidenceComparator=Comparator.comparing(pair -> pair.getSecond());
reportIdOrderTmp=IntStream.range(0,dataSet.getNumDataPoints()).parallel().mapToObj(i -> {
MultiLabel prediction=pluginPredictor.predict(dataSet.getRow(i));
double confidence=setScaling.calibratedProb(dataSet.getRow(i),prediction);
return new Pair<>(i,confidence);
}
).sorted(confidenceComparator.reversed()).map(Pair::getFirst).collect(Collectors.toList());
}
if (config.getString("String_Node_Str").equals("String_Node_Str")) {
Comparator<Pair<Integer,Double>> mistakeComparator=Comparator.comparing(pair -> pair.getSecond());
reportIdOrderTmp=IntStream.range(0,dataSet.getNumDataPoints()).parallel().mapToObj(i -> {
MultiLabel prediction=pluginPredictor.predict(dataSet.getRow(i));
double confidence=setScaling.calibratedProb(dataSet.getRow(i),prediction);
double instanceF1=FMeasure.f1(prediction,dataSet.getMultiLabels()[i]);
return new Pair<>(i,(1 - instanceF1) * confidence);
}
).sorted(mistakeComparator.reversed()).map(Pair::getFirst).collect(Collectors.toList());
}
final List<Integer> reportIdOrder=reportIdOrderTmp;
boolean simpleCSV=true;
if (simpleCSV) {
logger.info("String_Node_Str");
double probThreshold=config.getDouble("String_Node_Str");
File csv=new File(analysisFolder,"String_Node_Str");
List<String> strs=reportIdOrder.stream().parallel().map(i -> IMLGBInspector.simplePredictionAnalysisCalibrated(boosting,setScaling,labelScaling,pluginPredictor,dataSet,i,probThreshold)).collect(Collectors.toList());
try (BufferedWriter bw=new BufferedWriter(new FileWriter(csv))){
for (String line : strs) {
bw.write(line);
}
}
 logger.info("String_Node_Str");
}
boolean rulesToJson=config.getBoolean("String_Node_Str");
if (rulesToJson) {
logger.info("String_Node_Str");
int ruleLimit=config.getInt("String_Node_Str");
int numDocsPerFile=config.getInt("String_Node_Str");
int numFiles=(int)Math.ceil((double)dataSet.getNumDataPoints() / numDocsPerFile);
double probThreshold=config.getDouble("String_Node_Str");
int labelSetLimit=config.getInt("String_Node_Str");
IntStream.range(0,numFiles).forEach(i -> {
int start=i * numDocsPerFile;
int end=start + numDocsPerFile;
List<MultiLabelPredictionAnalysis> partition=IntStream.range(start,Math.min(end,dataSet.getNumDataPoints())).parallel().mapToObj(a -> IMLGBInspector.analyzePredictionCalibrated(boosting,setScaling,labelScaling,pluginPredictor,dataSet,reportIdOrder.get(a),ruleLimit,labelSetLimit,probThreshold)).collect(Collectors.toList());
ObjectMapper mapper=new ObjectMapper();
String file="String_Node_Str" + (i + 1) + "String_Node_Str";
try {
mapper.writeValue(new File(analysisFolder,file),partition);
}
 catch (IOException e) {
e.printStackTrace();
}
logger.info("String_Node_Str" + Progress.percentage(i + 1,numFiles));
}
);
logger.info("String_Node_Str");
}
boolean dataInfoToJson=true;
if (dataInfoToJson) {
logger.info("String_Node_Str");
Set<String> modelLabels=IntStream.range(0,boosting.getNumClasses()).mapToObj(i -> boosting.getLabelTranslator().toExtLabel(i)).collect(Collectors.toSet());
Set<String> dataSetLabels=DataSetUtil.gatherLabels(dataSet).stream().map(i -> dataSet.getLabelTranslator().toExtLabel(i)).collect(Collectors.toSet());
JsonGenerator jsonGenerator=new JsonFactory().createGenerator(new File(analysisFolder,"String_Node_Str"),JsonEncoding.UTF8);
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("String_Node_Str",dataName);
jsonGenerator.writeNumberField("String_Node_Str",boosting.getNumClasses());
jsonGenerator.writeNumberField("String_Node_Str",dataSetLabels.size());
jsonGenerator.writeNumberField("String_Node_Str",dataSet.getNumClasses());
Set<String> modelNotDataLabels=SetUtil.complement(modelLabels,dataSetLabels);
Set<String> dataNotModelLabels=SetUtil.complement(dataSetLabels,modelLabels);
jsonGenerator.writeNumberField("String_Node_Str",dataNotModelLabels.size());
jsonGenerator.writeNumberField("String_Node_Str",modelNotDataLabels.size());
jsonGenerator.writeArrayFieldStart("String_Node_Str");
for (String label : dataNotModelLabels) {
jsonGenerator.writeObject(label);
}
jsonGenerator.writeEndArray();
jsonGenerator.writeArrayFieldStart("String_Node_Str");
for (String label : modelNotDataLabels) {
jsonGenerator.writeObject(label);
}
jsonGenerator.writeEndArray();
jsonGenerator.writeNumberField("String_Node_Str",dataSet.labelCardinality());
jsonGenerator.writeEndObject();
jsonGenerator.close();
logger.info("String_Node_Str");
}
boolean modelConfigToJson=true;
if (modelConfigToJson) {
logger.info("String_Node_Str");
ObjectMapper objectMapper=new ObjectMapper();
objectMapper.writeValue(new File(analysisFolder,"String_Node_Str"),config);
logger.info("String_Node_Str");
}
boolean dataConfigToJson=true;
if (dataConfigToJson) {
logger.info("String_Node_Str");
File dataConfigFile=Paths.get(config.getString("String_Node_Str"),"String_Node_Str",dataName,"String_Node_Str").toFile();
if (dataConfigFile.exists()) {
FileUtils.copyFileToDirectory(dataConfigFile,analysisFolder);
}
logger.info("String_Node_Str");
}
boolean performanceToJson=true;
if (performanceToJson) {
ObjectMapper objectMapper=new ObjectMapper();
objectMapper.writeValue(new File(analysisFolder,"String_Node_Str"),mlMeasures);
}
boolean individualPerformance=true;
if (individualPerformance) {
logger.info("String_Node_Str");
ObjectMapper objectMapper=new ObjectMapper();
objectMapper.writeValue(new File(analysisFolder,"String_Node_Str"),mlMeasures.getMacroAverage());
logger.info("String_Node_Str");
}
if (config.getBoolean("String_Node_Str")) {
logger.info("String_Node_Str");
Config savedApp1Config=new Config(Paths.get(config.getString("String_Node_Str"),"String_Node_Str","String_Node_Str").toFile());
List<String> hosts=savedApp1Config.getStrings("String_Node_Str");
List<Integer> ports=savedApp1Config.getIntegers("String_Node_Str");
if (savedApp1Config.getString("String_Node_Str").equals("String_Node_Str")) {
hosts=new ArrayList<>();
for (int port : ports) {
hosts.add("String_Node_Str");
}
hosts.add("String_Node_Str");
ports.add(9200);
}
try (Visualizer visualizer=new Visualizer(logger,hosts,ports)){
visualizer.produceHtml(analysisFolder);
logger.info("String_Node_Str");
}
 }
logger.info("String_Node_Str");
}