Program: 143993
Project: 143993
Buggy source:
public ImportedDataSet(Set<Label> labels,Map<DataInstance<Vector>,Map<Label,Boolean>> dataSet,Map<DataInstance<Vector>,Map<Label,Boolean>> evaluationDataSet,double l1RegularizationWeight,double l2RegularizationWeight){
  this.labels=labels;
  this.dataSet=dataSet;
  this.evaluationDataSet=evaluationDataSet;
  statistics=new HashMap<>();
  for (  Label label : labels)   statistics.put(label,new DataSetStatistics());
  for (  Map.Entry<DataInstance<Vector>,Map<Label,Boolean>> instanceEntry : dataSet.entrySet()) {
    for (    Map.Entry<Label,Boolean> instanceLabelEntry : instanceEntry.getValue().entrySet()) {
      if (instanceLabelEntry.getValue())       statistics.get(instanceLabelEntry.getKey()).numberOfPositiveExamples++;
 else       statistics.get(instanceLabelEntry.getKey()).numberOfNegativeExamples++;
      statistics.get(instanceLabelEntry.getKey()).totalNumberOfExamples++;
    }
  }
  predictedDataSet=new HashMap<>();
  evaluationPredictedDataSet=new HashMap<>();
  classifiers=new HashMap<>();
  for (  Label label : labels) {
    predictedDataSet.put(label,new DataSetInMemory<>());
    evaluationPredictedDataSet.put(label,new DataSetInMemory<>());
    Vector randomFeatureVector=dataSet.keySet().iterator().next().features();
    LogisticRegressionAdaGrad.Builder classifierBuilder=new LogisticRegressionAdaGrad.Builder(randomFeatureVector.size()).useBiasTerm(true).l1RegularizationWeight(l1RegularizationWeight).l2RegularizationWeight(l2RegularizationWeight).loggingLevel(0).sampleWithReplacement(true).maximumNumberOfIterations(1000).maximumNumberOfIterationsWithNoPointChange(10).pointChangeTolerance(1e-5).checkForPointConvergence(true).batchSize(100);
    if (randomFeatureVector instanceof DenseVector)     classifierBuilder.sparse(false);
 else     classifierBuilder.sparse(true);
    classifiers.put(label,classifierBuilder.build());
  }
  for (  Map.Entry<DataInstance<Vector>,Map<Label,Boolean>> instanceEntry : dataSet.entrySet())   for (  Map.Entry<Label,Boolean> instanceLabelEntry : instanceEntry.getValue().entrySet()) {
    PredictedDataInstance<Vector,Double> predictedInstance=new PredictedDataInstance<>(instanceEntry.getKey().name(),instanceEntry.getKey().features(),instanceLabelEntry.getValue() ? 1.0 : 0.0,null,1.0);
    predictedDataSet.get(instanceLabelEntry.getKey()).add(predictedInstance);
  }
  for (  Map.Entry<DataInstance<Vector>,Map<Label,Boolean>> instanceEntry : evaluationDataSet.entrySet())   for (  Map.Entry<Label,Boolean> instanceLabelEntry : instanceEntry.getValue().entrySet()) {
    PredictedDataInstance<Vector,Double> predictedInstance=new PredictedDataInstance<>(instanceEntry.getKey().name(),instanceEntry.getKey().features(),instanceLabelEntry.getValue() ? 1.0 : 0.0,null,1.0);
    evaluationPredictedDataSet.get(instanceLabelEntry.getKey()).add(predictedInstance);
  }
  labels.stream().forEach(label -> {
    classifiers.get(label).train(predictedDataSet.get(label));
    classifiers.get(label).predictInPlace(evaluationPredictedDataSet.get(label));
    for (    PredictedDataInstance<Vector,Double> instance : evaluationPredictedDataSet.get(label))     if (instance.label() < 0.5) {
      instance.label(1 - instance.label());
      instance.probability(1 - instance.probability());
    }
  }
);
}

Fixed version (ground truth):
public ImportedDataSet(Set<Label> labels,Map<DataInstance<Vector>,Map<Label,Boolean>> dataSet,Map<DataInstance<Vector>,Map<Label,Boolean>> evaluationDataSet,double l1RegularizationWeight,double l2RegularizationWeight){
  this.labels=labels;
  this.dataSet=dataSet;
  this.evaluationDataSet=evaluationDataSet;
  statistics=new HashMap<>();
  for (  Label label : labels)   statistics.put(label,new DataSetStatistics());
  for (  Map.Entry<DataInstance<Vector>,Map<Label,Boolean>> instanceEntry : dataSet.entrySet()) {
    for (    Map.Entry<Label,Boolean> instanceLabelEntry : instanceEntry.getValue().entrySet()) {
      if (instanceLabelEntry.getValue())       statistics.get(instanceLabelEntry.getKey()).numberOfPositiveExamples++;
 else       statistics.get(instanceLabelEntry.getKey()).numberOfNegativeExamples++;
      statistics.get(instanceLabelEntry.getKey()).totalNumberOfExamples++;
    }
  }
  Map<Label,DataSet<PredictedDataInstance<Vector,Double>>> predictedDataSet=new HashMap<>();
  evaluationPredictedDataSetInstances=new HashMap<>();
  classifiers=new HashMap<>();
  for (  Label label : labels) {
    predictedDataSet.put(label,new DataSetInMemory<>());
    evaluationPredictedDataSetInstances.put(label,new DataSetInMemory<>());
    Vector randomFeatureVector=dataSet.keySet().iterator().next().features();
    LogisticRegressionAdaGrad.Builder classifierBuilder=new LogisticRegressionAdaGrad.Builder(randomFeatureVector.size()).useBiasTerm(true).l1RegularizationWeight(l1RegularizationWeight).l2RegularizationWeight(l2RegularizationWeight).loggingLevel(0).sampleWithReplacement(true).maximumNumberOfIterations(1000).maximumNumberOfIterationsWithNoPointChange(10).pointChangeTolerance(1e-5).checkForPointConvergence(true).batchSize(100);
    if (randomFeatureVector instanceof DenseVector)     classifierBuilder.sparse(false);
 else     classifierBuilder.sparse(true);
    classifiers.put(label,classifierBuilder.build());
  }
  for (  Map.Entry<DataInstance<Vector>,Map<Label,Boolean>> instanceEntry : dataSet.entrySet())   for (  Map.Entry<Label,Boolean> instanceLabelEntry : instanceEntry.getValue().entrySet()) {
    PredictedDataInstance<Vector,Double> predictedInstance=new PredictedDataInstance<>(instanceEntry.getKey().name(),instanceEntry.getKey().features(),instanceLabelEntry.getValue() ? 1.0 : 0.0,null,1.0);
    predictedDataSet.get(instanceLabelEntry.getKey()).add(predictedInstance);
  }
  for (  Map.Entry<DataInstance<Vector>,Map<Label,Boolean>> instanceEntry : evaluationDataSet.entrySet())   for (  Map.Entry<Label,Boolean> instanceLabelEntry : instanceEntry.getValue().entrySet()) {
    PredictedDataInstance<Vector,Double> predictedInstance=new PredictedDataInstance<>(instanceEntry.getKey().name(),instanceEntry.getKey().features(),instanceLabelEntry.getValue() ? 1.0 : 0.0,null,1.0);
    evaluationPredictedDataSetInstances.get(instanceLabelEntry.getKey()).add(predictedInstance);
  }
  labels.stream().forEach(label -> {
    classifiers.get(label).train(predictedDataSet.get(label));
    classifiers.get(label).predictInPlace(evaluationPredictedDataSetInstances.get(label));
    for (    PredictedDataInstance<Vector,Double> instance : evaluationPredictedDataSetInstances.get(label))     if (instance.label() < 0.5) {
      instance.label(1 - instance.label());
      instance.probability(1 - instance.probability());
    }
  }
);
  evaluationPredictedDataSet=new HashMap<>();
  for (  Map.Entry<Label,DataSet<PredictedDataInstance<Vector,Double>>> instanceEntry : evaluationPredictedDataSetInstances.entrySet()) {
    for (    PredictedDataInstance<Vector,Double> predictedInstance : instanceEntry.getValue()) {
      DataInstance<Vector> instance=new DataInstance<>(predictedInstance.name(),predictedInstance.features());
      if (!evaluationPredictedDataSet.containsKey(instance))       evaluationPredictedDataSet.put(instance,new HashMap<>());
      evaluationPredictedDataSet.get(instance).put(instanceEntry.getKey(),predictedInstance.probability());
    }
  }
}