public static void latexOutput(BenchPerformance[] tests, PrintStream ps) {
    String header = "\\begin{tabular}{|l|";
    for (int i = 0; i < tests.length; i++) header += "r";
    header += "|}";
    ps.println(header);
    ps.println("\\hline");

    ps.printf("%35s ", "measure");
    for (BenchPerformance t : tests) ps.printf("& %10s ", t.g.getId());
    ps.println("\\\\");
    ps.println("\\hline");

    for (Measures m : Measures.values()) {
      // skip if not measured
      if (!tests[0].measureValues.containsKey(m)) continue;
      ps.printf("%35s ", "\\lstinline~" + m.name() + "~");
      for (BenchPerformance t : tests) {
        double val = t.measureValues.get(m);
        if (m == Measures.MEMORY) val /= 1 << 20;
        else val /= 1000;
        ps.printf("& %10.3f ", val);
      }
      ps.println("\\\\");
    }
    ps.println("\\hline");
    ps.println("\\end{tabular}");
  }
Exemple #2
0
  /**
   * Computes performance measures of a tree
   *
   * @param inst itemsets
   * @param smooth =true uses the smoothed models; otherwise uses the unsmoothed models
   * @return the performance measures
   * @exception Exception if something goes wrong
   */
  public final Measures measures(MyDataset inst, boolean smooth) throws Exception {

    int i, numItemsets, count;
    double sd, y1[], y2[];
    Measures measures = new Measures();

    errors = this.errors(inst, smooth);
    numItemsets = errors.numItemsets - errors.missingItemsets;
    y1 = new double[numItemsets];
    y2 = new double[numItemsets];
    count = 0;
    for (i = 0; i <= inst.numItemsets() - 1; i++) {
      y1[count] = this.predict(inst.itemset(i), smooth);
      y2[count] = inst.itemset(i).getClassValue();
      count++;
    }

    measures.correlation = M5.correlation(y1, y2, numItemsets);

    sd = M5.stdDev(inst.getClassIndex(), inst);
    if (sd > 0.0) {
      measures.meanAbsErr = errors.meanAbsErr;
      measures.meanSqrErr = errors.meanSqrErr;
      measures.type = 0;
    } else {
      if (numItemsets >= 1) {
        measures.type = 1;
        measures.meanAbsErr = errors.meanAbsErr;
        measures.meanSqrErr = errors.meanSqrErr;
      } else {
        measures.type = 2;
        measures.meanAbsErr = 0.0;
        measures.meanSqrErr = 0.0;
      }
    }

    return measures;
  }
 @Test
 public void testSetData() {
   measures.setData(Metric.LCOM4_BLOCKS, "blocks detail");
   assertEquals("blocks detail", measures.getData(Metric.LCOM4_BLOCKS));
 }
 @Test
 public void testSetValue() {
   measures.setValue(Metric.ACCESSORS, 3);
   assertEquals(3, measures.getValue(Metric.ACCESSORS), 0.1);
 }
 @Test
 public void testGetData() {
   assertNull(measures.getData(Metric.LCOM4_BLOCKS));
 }
 @Test
 public void testGetValue() {
   assertEquals(0, measures.getValue(Metric.ACCESSORS), 0.1);
 }