Пример #1
0
  @Override
  public void perform() throws TaskException {

    try {
      Instances[] data = this.readAndCheckData();

      for (int i = 0; i < data.length; ++i) {
        String oldName = data[i].relationName();
        Filter filter = this.initFilter(data[i]);
        data[i] = Filter.useFilter(data[i], filter);
        data[i].setRelationName(oldName); // keep the old relation name
        FileUtils.writeArff(this.output.get(i), data[i]);
      }
    } catch (TaskException e) {
      throw e;
    } catch (Exception e) {
      Logger.getInstance().logStackTrace(e, Logger.V_DEBUG);
      throw new TaskException(TaskException.ERR_IO_ERROR, this.id, e.getMessage());
    }
  }
Пример #2
0
  @Override
  protected void manipulateAttributes(Instances data) throws TaskException {

    String[] attribs = this.getParameterVal(ATTRIBS).split("\\s+");

    for (int i = 0; i < attribs.length; ++i) {
      if (data.attribute(attribs[i]) == null) {
        Logger.getInstance()
            .message(
                "Attribute " + attribs[i] + " not found in data set " + data.relationName(),
                Logger.V_WARNING);
        continue;
      }
      Enumeration<Instance> insts = data.enumerateInstances();
      int attrIndex = data.attribute(attribs[i]).index();

      while (insts.hasMoreElements()) {
        Instance inst = insts.nextElement();
        inst.setMissing(attrIndex);
      }
    }
  }