예제 #1
0
    /** Split and return test or train instances. */
    Instances split(Instances data, boolean invert, boolean removeAttribute) throws Exception {
      super.setInvertSelection(invert);
      super.setNominalIndicesArr(toValueIndexArray(getAttribute(data)));

      final Filter filter;
      if (!removeAttribute) filter = this;
      else {
        Remove remove = new Remove();
        remove.setAttributeIndices(super.getAttributeIndex());
        MultiFilter mf = new MultiFilter();
        mf.setFilters(new Filter[] {this, remove});
        filter = mf;
      }
      filter.setInputFormat(data);
      return Filter.useFilter(data, filter);
    }
예제 #2
0
 @Override
 public boolean setInputFormat(Instances instanceInfo) throws Exception {
   super.setNominalIndicesArr(toValueIndexArray(getAttribute(instanceInfo)));
   return super.setInputFormat(instanceInfo);
 }