double totPos = 0, totNeg = 0; double [] probs = getProbabilities(predictions, classIndex);   for (int i = 0; i < probs.length; i++) { NominalPrediction pred = (NominalPrediction)predictions.elementAt(i); if (pred.actual() == Prediction.MISSING_VALUE) { System.err.println(getClass().getName() + " Skipping prediction with missing class value"); continue; } if (pred.weight() < 0) { System.err.println(getClass().getName() + " Skipping prediction with negative weight"); continue; } if (pred.actual() == classIndex) { totPos += pred.weight(); } else { totNeg += pred.weight(); } }  Instances insts = makeHeader(); int [] sorted = Utils.sort(probs); TwoClassStats tc = new TwoClassStats(totPos, totNeg, 0, 0); for (int i = 0; i < sorted.length; i++) { NominalPrediction pred = (NominalPrediction)predictions.elementAt(sorted[i]); if (pred.actual() == Prediction.MISSING_VALUE) { System.err.println(getClass().getName() + " Skipping prediction with missing class value"); continue; } if (pred.weight() < 0) { System.err.println(getClass().getName() + " Skipping prediction with negative weight"); continue; } if (pred.actual() == classIndex) { tc.setTruePositive(tc.getTruePositive() - pred.weight()); tc.setFalseNegative(tc.getFalseNegative() + pred.weight()); } else { tc.setFalsePositive(tc.getFalsePositive() - pred.weight()); tc.setTrueNegative(tc.getTrueNegative() + pred.weight()); }  if ((i != (sorted.length - 1)) && ((i == 0) || (probs[sorted[i]] != probs[sorted[i - 1]]))) { insts.add(makeInstance(tc, probs[sorted[i]])); } } return insts;
return getCurve(predictions, ((NominalPrediction)predictions.elementAt(0)) .distribution().length - 1);
  public Instances getCurve(FastVector predictions, int classIndex) {    if ((predictions.size() == 0) ||        (((NominalPrediction)predictions.elementAt(0))         .distribution().length <= classIndex)) {      return null;    }    double totPos = 0, totNeg = 0;    double [] probs = getProbabilities(predictions, classIndex);    // Get distribution of positive/negatives    for (int i = 0; i < probs.length; i++) {      NominalPrediction pred = (NominalPrediction)predictions.elementAt(i);      if (pred.actual() == Prediction.MISSING_VALUE) {        System.err.println(getClass().getName()                            + " Skipping prediction with missing class value");        continue;      }      if (pred.weight() < 0) {        System.err.println(getClass().getName()                            + " Skipping prediction with negative weight");        continue;      }      if (pred.actual() == classIndex) {        totPos += pred.weight();      } else {        totNeg += pred.weight();      }    }    Instances insts = makeHeader();    int [] sorted = Utils.sort(probs);    TwoClassStats tc = new TwoClassStats(totPos, totNeg, 0, 0);    for (int i = 0; i < sorted.length; i++) {      NominalPrediction pred = (NominalPrediction)predictions.elementAt(sorted[i]);      if (pred.actual() == Prediction.MISSING_VALUE) {        System.err.println(getClass().getName()                           + " Skipping prediction with missing class value");        continue;      }      if (pred.weight() < 0) {        System.err.println(getClass().getName()                            + " Skipping prediction with negative weight");        continue;      }      if (pred.actual() == classIndex) {        tc.setTruePositive(tc.getTruePositive() - pred.weight());        tc.setFalseNegative(tc.getFalseNegative() + pred.weight());      } else {        tc.setFalsePositive(tc.getFalsePositive() - pred.weight());        tc.setTrueNegative(tc.getTrueNegative() + pred.weight());      }      /*      System.out.println(tc + " " + probs[sorted[i]]                          + " " + (pred.actual() == classIndex));      */      if ((i != (sorted.length - 1)) &&          ((i == 0) ||            (probs[sorted[i]] != probs[sorted[i - 1]]))) {        insts.add(makeInstance(tc, probs[sorted[i]]));      }    }    return insts;  }