Esempio n. 1
0
  /**
   * Creates labels with the squared error sums for the different clusters, as well as creates one
   * total squared error, which is the sum of the squared error from the different clusters
   *
   * @param r
   * @return
   */
  private ArrayList<Label> getSquaredErrors(Results r) {
    ArrayList<Label> errorLabels = new ArrayList<>();
    double[] errors = r.getSquaredErrors();
    double totalErrors = 0;
    errorLabels.add(new Label(" ")); // Adds an empty row

    // Calculate the number of digits in the largest error.
    // This'll be used to place the numbers in the labels correctly
    double largestNr = 0;
    for (double d : errors) {
      if (Math.abs(d) > largestNr) largestNr = Math.abs(d);
    }
    int offset = (int) (Math.log10(largestNr) + 6);

    for (int i = 0; i < errors.length; i++) {
      Label label = new Label(String.format("SSE Clu" + i + ": %" + offset + ".4f", errors[i]));
      DataTable.skinDataLabel(label);

      totalErrors += errors[i];

      errorLabels.add(label);
    }

    Label blank = new Label(" ");
    Label total = new Label("Total SSE");
    Label val = new Label(String.format("%.4f", totalErrors));

    total.setStyle("-fx-underline: true;");
    DataTable.skinDataLabel(blank);
    DataTable.skinDataLabel(total);
    DataTable.skinDataLabel(val);

    errorLabels.add(blank);
    errorLabels.add(total);
    errorLabels.add(val);
    return errorLabels;
  }
Esempio n. 2
0
  private ArrayList<Label> getMiscDataLabels(Results r) {
    ArrayList<Label> miscDataLabels = new ArrayList<>();
    ArrayList<Pair<String, Double>> miscData = r.getMiscData();

    miscDataLabels.add(new Label(" ")); // Adds an empty row

    for (int i = 0; i < miscData.size(); i++) {
      Pair<String, Double> data = miscData.get(i);

      Label label = new Label(data.left + ": " + data.right);
      DataTable.skinDataLabel(label);

      miscDataLabels.add(label);
    }

    return miscDataLabels;
  }