Remove+Attributes

toc The following code removes specified attributes from an ARFF file and prints the result to stdout.

The class takes the following parameters: code format="java" import weka.core.Instances; import weka.filters.Filter; import weka.filters.unsupervised.attribute.Remove; import java.io.BufferedReader; import java.io.FileReader; public class RemoveTest { /**   * takes an ARFF file as first argument, the number of indices to remove * as second and thirdly whether to invert or not (true/false). * Dumps the generated data to stdout. */  public static void main(String[] args) throws Exception { Instances      inst; Instances      instNew; Remove         remove; inst  = new Instances(new BufferedReader(new FileReader(args[0]))); remove = new Remove; remove.setAttributeIndices(args[1]); remove.setInvertSelection(new Boolean(args[2]).booleanValue); remove.setInputFormat(inst); instNew = Filter.useFilter(inst, remove); System.out.println(instNew); } } code The same can be achieved with the following filter commandline (add to invert the selection): code format="bash" java weka.filters.unsupervised.attribute.Remove -R -i -o code
 * ARFF file
 * attribute index/indices
 * inversion of index/indices (false/true)

= Downloads =
 * ([|book], [|stable-3.6], [|developer])