Ejemplo n.º 1
0
  /**
   * * Create a FastVector containing the set of values found in the given row...
   *
   * <p>NOTE: As it happens, this function determines the order of the attribute values, an order
   * that will percolate throughout wekaMine and influence all subsequent displays.
   *
   * <p>Originally the valSet was a HashSet and the iteration order of that will depend on the hash
   * code for the key, and may seem random. While we would not like to rely on the order of
   * attributes, it seems desirable to make the attribute order somehow comprehensible, either sort
   * order or insertion order. Insertion order will seem random also because it is determined by the
   * arbitrary order of the instances. So it has been changed to a TreeSet which will be ordered by
   * the natural ordering of it's elements.
   */
  public FastVector getRowValues(Table t, int rowIdx) {
    TreeSet<String> valSet = new TreeSet<String>();
    for (int c = 0; c < t.cols(); c++) {
      String val = (String) t.matrix.getQuick(rowIdx, c);

      if (val == null) {
        System.err.println("null value in row:" + rowIdx + " col:" + c);
        for (int i = 0; i < t.cols(); i++) {
          System.err.println("\t" + i + "\t" + t.matrix.getQuick(rowIdx, c));
        }
      }

      // Don't want to include "missing value" as one of the nominal values...
      if (!val.equals("?")) {
        valSet.add(val);
      }
    }

    FastVector attVals = new FastVector();
    for (Object v : valSet) {
      attVals.addElement(v);
    }
    return (attVals);
  }
Ejemplo n.º 2
0
  /** * Create a FastVector containing the set of values found in the given col... */
  public FastVector getColValues(Table t, int colIdx) {
    HashSet<String> valSet = new HashSet<String>();
    for (int r = 0; r < t.rows(); r++) {
      String val = (String) t.matrix.getQuick(r, colIdx);

      if (val == null) {
        System.err.println("\nDEBUG r=" + r + "\tc=" + colIdx + "\tval=" + val);
        System.err.println("\nDEBUG r=" + t.rowNames[r] + "\tc=" + t.colNames[colIdx]);
      }

      // Don't want to include "missing value" as one of the nominal values...
      if (val != null) {
        if (!val.equals("?")) {
          valSet.add(val);
        }
      }
    }
    FastVector attVals = new FastVector();
    for (Object v : valSet) {
      attVals.addElement(v);
    }
    return (attVals);
  }