Пример #1
0
  /**
   * Function to read an itemset and appends it to the dataset.
   *
   * @return True if the itemset was readed succesfully.
   */
  private boolean getItemsetFull() {

    // fill itemset
    for (int j = 0; j < IS.getNumInstances(); j++) {

      double[] itemset = new double[Attributes.getNumAttributes()];
      int index;

      // Get values for all input attributes.
      for (int i = 0; i < Attributes.getInputNumAttributes(); i++) {

        // check type and if there is null

        if (IS.getInstance(j).getInputMissingValues(i)) itemset[i] = Itemset.getMissingValue();
        else {
          if (Attributes.getInputAttribute(i).getType() == 0) // nominal
          {
            for (int k = 0; k < Attributes.getInputAttribute(i).getNumNominalValues(); k++)
              if (Attributes.getInputAttribute(i)
                  .getNominalValue(k)
                  .equals(IS.getInstance(j).getInputNominalValues(i))) itemset[i] = (double) k;
          } else // real and integer
          {
            itemset[i] = IS.getInstance(j).getInputRealValues(i);
          }
        } // else
      } // for

      // Get values for output attribute.
      int i = Attributes.getInputNumAttributes();

      // check type and if there is null
      if (IS.getInstance(j).getOutputMissingValues(0)) itemset[i] = Itemset.getMissingValue();
      else {
        if (Attributes.getOutputAttribute(0).getType() == 0) // nominal
        {
          for (int k = 0; k < Attributes.getOutputAttribute(0).getNumNominalValues(); k++)
            if (Attributes.getOutputAttribute(0)
                .getNominalValue(k)
                .equals(IS.getInstance(j).getOutputNominalValues(0))) itemset[i] = (double) k;
        } else // real and integer
        {
          itemset[i] = IS.getInstance(j).getOutputRealValues(0);
        }
      } // else

      // Add itemset to dataset
      addItemset(new Itemset(1, itemset));
    } // for

    return true;
  }
Пример #2
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);
  }