Exemplo n.º 1
0
  /**
   * Expects a filename as first and second parameter.
   *
   * @param args the command-line parameters
   * @throws Exception if something goes wrong
   */
  public static void main(String[] args) throws Exception {
    // output usage
    if (args.length != 2) {
      System.err.println("\nUsage: java SaveDataToAnyFile <input> <output>\n");
      System.exit(1);
    }

    System.out.println("\nReading from file " + args[0] + "...");
    Instances data = DataSource.read(args[0]);

    System.out.println("\nSaving to file " + args[1] + "...");
    DataSink.write(args[1], data);
  }
Exemplo n.º 2
0
  public static void main(String[] args) throws Exception {
    if (args.length != 3)
      throw new IllegalArgumentException(
          "Required parameters: <input> <attribute_indices> <output>");

    System.out.println("Loading input data: " + args[0]);
    Instances input = DataSource.read(args[0]);

    System.out.println("Applying filter using indices: " + args[1]);
    MekaClassAttributes filter = new MekaClassAttributes();
    filter.setAttributeIndices(args[1]);
    filter.setInputFormat(input);
    Instances output = Filter.useFilter(input, filter);

    System.out.println("Saving filtered data to: " + args[2]);
    ArffSaver saver = new ArffSaver();
    saver.setFile(new File(args[2]));
    DataSink.write(saver, output);
  }