Example usage for weka.attributeSelection AttributeSelection CrossValidateAttributes

List of usage examples for weka.attributeSelection AttributeSelection CrossValidateAttributes

Introduction

In this page you can find the example usage for weka.attributeSelection AttributeSelection CrossValidateAttributes.

Prototype

public String CrossValidateAttributes() throws Exception 

Source Link

Document

Perform a cross validation for attribute selection.

Usage

From source file:old.CFS.java

/**
 * uses the low level approach//from ww w  .  ja  v a 2 s.  com
   * @param data
 */
protected static void useLowLevel(Instances data) throws Exception {
    System.out.println("\n3. Low-level");
    AttributeSelection attsel = new AttributeSelection();
    ChiSquaredAttributeEval eval = new ChiSquaredAttributeEval();
    Ranker search = new Ranker();
    search.setThreshold(-1.7976931348623157E308);
    search.setNumToSelect(1000);
    attsel.setEvaluator(eval);
    attsel.setSearch(search);
    attsel.setFolds(10);
    attsel.setXval(true);
    attsel.SelectAttributes(data);
    //    System.out.println(data.toSummaryString());
    //    attsel.selectAttributesCVSplit(data);
    //    attsel.SelectAttributes(data);

    System.out.println(attsel.CrossValidateAttributes());
    //    attsel.SelectAttributes(data);
    //    attsel.selectAttributesCVSplit(data);
    Instances newData = attsel.reduceDimensionality(data);

    int[] indices = attsel.selectedAttributes();
    System.out.println(newData);
    System.out.println("selected attribute indices (starting with 0):\n" + Utils.arrayToString(indices));
}