Example usage for weka.attributeSelection BestFirst setLookupCacheSize

List of usage examples for weka.attributeSelection BestFirst setLookupCacheSize

Introduction

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

Prototype

public void setLookupCacheSize(int size) 

Source Link

Document

Set the maximum size of the evaluated subset cache (hashtable).

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);/*from w  w  w  .  ja  va2 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));
}