Example usage for weka.attributeSelection BestFirst setOptions

List of usage examples for weka.attributeSelection BestFirst setOptions

Introduction

In this page you can find the example usage for weka.attributeSelection BestFirst setOptions.

Prototype

@Override
public void setOptions(String[] options) throws Exception 

Source Link

Document

Parses a given list of options.

Usage

From source file:RunBestFirstSearch.java

License:Open Source License

protected static void runAttributeSelection(Instances data, int n) throws Exception {
    AttributeSelection attsel = new AttributeSelection();
    CfsSubsetEval cost_function = new CfsSubsetEval(); // CFS cost function.
    BestFirst algorithm = new BestFirst(); // BFS algorithm.

    cost_function.buildEvaluator(data);/*  w  ww  . j ava 2  s  .  c  o  m*/

    algorithm.setLookupCacheSize(n);

    // BFS with forward direction and terminating search after five
    // non-improving nodes.
    //
    String[] parameters = { "-D 1", "-N 5" };

    algorithm.setOptions(parameters);

    cost_function.setLocallyPredictive(false);

    attsel.setEvaluator(cost_function);
    attsel.setSearch(algorithm);

    attsel.SelectAttributes(data);

    int[] indices = attsel.selectedAttributes();

    System.out.println("Selected features:\n" + Utils.arrayToString(indices));
}