예제 #1
0
  private Node getReferenceTable(Results r) {
    String[] subH = new String[r.getNumberOfClusters()];
    for (int i = 0; i < subH.length; i++) subH[i] = "Cluster " + i;

    DataTable refTable = new DataTable();
    refTable.addHiddenClusterHeaders(subH);

    // Fetch the reference labels
    String[] refLabels = r.getReferenceLabels();
    refTable.setLabelRowRelationship(getReferenceRowRelationship(refLabels));
    refTable.setTotalLabelCount(mRefLabelToRow.size());

    // For each cluster, we add the reference data means as labels, and link that data to the
    // corresponding label
    double[][] refMeans = r.getReferenceDataMeans();
    for (int col = 0; col < r.getNumberOfClusters(); col++) {
      ArrayList<Pair<String, String>> pairs = new ArrayList<Pair<String, String>>();
      double[] thisCol = refMeans[col];
      for (int j = 0; j < refLabels.length; j++) {
        Pair<String, String> pair =
            new Pair<String, String>(refLabels[j], String.valueOf(thisCol[j]));
        pairs.add(pair);
      }

      refTable.setColumnData(col, mRefLabelToRow.size(), pairs);
    }

    mRefDataTables.add(refTable);
    return refTable;
  }
예제 #2
0
  private Node getDataTable(Results r, Pane pane) {
    // The grid part contains the cluster's centoid data, as well as the "X" button
    String[] subH = new String[r.getNumberOfClusters()];
    for (int i = 0; i < subH.length; i++) subH[i] = "Cluster " + i;

    DataTable dataTable = new DataTable("Run " + mNextRun++, subH);

    // Fetch the labels. Inform the data table of the label-row relationships
    String[] labels = r.getLabels();
    dataTable.setLabelRowRelationship(getLabelRowRelationship(labels));
    dataTable.setTotalLabelCount(mDataLabelToRow.size());

    // For each cluster, we create a list of Label - Data pairs, where the label denotes what
    // feature we are looking at
    // and the Data represents that clusters centoid for the current feature
    for (int col = 0; col < r.getNumberOfClusters(); col++) {
      ArrayList<Pair<String, String>> labelDataPairs = new ArrayList<Pair<String, String>>();
      double[] clusterCentoid = r.getCentoid(col);

      for (int j = 0; j < labels.length; j++) {
        Pair<String, String> pair =
            new Pair<String, String>(labels[j], String.valueOf(clusterCentoid[j]));
        labelDataPairs.add(pair);
      }

      dataTable.setColumnData(col, mDataLabelToRow.size(), labelDataPairs);
    }

    dataTable.addCloseButton(pane);

    mDataTables.add(dataTable);
    return dataTable;
  }
예제 #3
0
  private Integer addNewRefLabel(String currLabel) {
    // Register a new relationship within this tab
    mRefLabelToRow.put(currLabel, mNextRefLabelIndex);

    // Paint the new label at the bottom of the reference label table
    mRefLabelTable.appendText(currLabel);

    // Add empty spaces to all other ref data tables
    for (DataTable t : mRefDataTables) t.addEmptyRow();

    return mNextRefLabelIndex++;
  }
예제 #4
0
  private int addNewDataLabel(String label) {
    // Register a new relationship within this tab
    mDataLabelToRow.put(label, mNextLabelIndex);

    // Paint the new label at the bottom of the label table
    mLabelTable.appendText(label);

    // Add empty spaces to all other data tables
    for (DataTable t : mDataTables) t.addEmptyRow();

    return mNextLabelIndex++;
  }
예제 #5
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;
  }
예제 #6
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;
  }
예제 #7
0
  /** Creates the basic layout, with the left label grid and the similar */
  private void createBaseLayout() {
    label_box = new VBox();
    wrap_pane.getChildren().add(label_box);

    mLabelTable =
        new DataTable(
            " ",
            " "); // We want the extra spacing that having a heading gives, to keep in line with the
                  // data labels
    mRefLabelTable = new DataTable();
    mRefLabelTable.addHiddenClusterHeaders(" ");

    label_box.getChildren().add(mLabelTable);
    label_box.getChildren().add(mRefLabelTable);

    wrap_pane.setMinWidth(1);
    addVerticalSeparator();

    first = false;
  }