Ejemplo n.º 1
0
  /** Function to stores header of a data file. */
  private void readHeader() {
    String attributeName;
    Vector attributeValues;
    int i;

    name = Attributes.getRelationName();

    // Create vectors to hold information temporarily.
    attributes = new Vector();

    keel.Dataset.Attribute at;

    // store attribute,inputs and outputs of the header
    for (int j = 0; j < Attributes.getNumAttributes(); j++) {
      at = Attributes.getAttribute(j);
      attributeName = at.getName();

      // check if it is real
      if (at.getType() == 2) {
        float min = (float) at.getMinAttribute();
        float max = (float) at.getMinAttribute();
        attributes.addElement(new Attribute(attributeName, j));
        Attribute att = (Attribute) attributes.elementAt(j);
        att.setRange(min, max);
        att.activate();
      } else {
        if (at.getType() == 1) // check if it is integer
        {
          int min = (int) at.getMinAttribute();
          int max = (int) at.getMinAttribute();
          attributes.addElement(new Attribute(attributeName, j));
          Attribute att = (Attribute) attributes.elementAt(j);
          att.setRange(min, max);
          att.activate();
        } else // it is nominal
        {
          attributeValues = new Vector();
          for (int k = 0; k < at.getNumNominalValues(); k++) {
            attributeValues.addElement(at.getNominalValue(k));
          }
          attributes.addElement(new Attribute(attributeName, attributeValues, j));
          Attribute att = (Attribute) attributes.elementAt(j);
          att.activate();
        }
      }
    } // for

    // set the index of the output class
    classIndex = Attributes.getNumAttributes() - 1;
  }
Ejemplo n.º 2
0
  /**
   * Enumerates all the attributes.
   *
   * @return An enumeration that contains all the attributes.
   */
  public Enumeration enumerateAttributes() {
    Vector help = new Vector(attributes.size() - 1);

    for (int i = 0; i < attributes.size(); i++)
      if (i != classIndex) help.addElement(attributes.elementAt(i));

    return help.elements();
  }
Ejemplo n.º 3
0
  /**
   * Function to remove all the attributes with missing value in the given attribute.
   *
   * @param attIndex The index of the attribute.
   */
  public final void deleteWithMissing(int attIndex) {
    Vector newItemsets = new Vector(numItemsets());

    for (int i = 0; i < numItemsets(); i++)
      if (!itemset(i).isMissing(attIndex)) newItemsets.addElement(itemset(i));

    itemsets = newItemsets;
  }
Ejemplo n.º 4
0
  /**
   * Function to add one itemset.
   *
   * @param itemset The itemset to add to the dataset.
   */
  public final void addItemset(Itemset itemset) {
    Itemset newItemset = (Itemset) itemset.copy();

    newItemset.setDataset(this);
    itemsets.addElement(newItemset);
  }