Пример #1
0
  /**
   * Adds the supplied input instance to the inputformat dataset for later processing. Use this
   * method rather than getInputFormat().add(instance). Or else.
   *
   * @param instance the <code>Instance</code> to buffer.
   */
  protected void bufferInput(M5Instance instance) {

    if (instance != null) {
      copyStringValues(instance, m_InputFormat, m_InputStringAtts);
      instance.setDataset(m_InputFormat);
      m_InputFormat.add(instance);
    }
  }
Пример #2
0
  /**
   * Filters an entire set of instances through a filter and returns the new set.
   *
   * @param data the data to be filtered
   * @param filter the filter to be used
   * @return the filtered set of data
   * @exception Exception if the filter can't be used successfully
   */
  public static M5Instances useFilter(M5Instances data, NominalToBinaryFilter filter)
      throws Exception {
    /*
        System.err.println(filter.getClass().getName()
                      + " in:" + data.numInstances());
    */
    for (int i = 0; i < data.numInstances(); i++) {
      filter.input(data.instance(i));
    }
    filter.batchFinished();
    M5Instances newData = filter.getOutputFormat();
    M5Instance processed;
    while ((processed = filter.output()) != null) {
      newData.add(processed);
    }

    /*
        System.err.println(filter.getClass().getName()
                      + " out:" + newData.numInstances());
    */
    return newData;
  }