Example usage for weka.attributeSelection SVMAttributeEval SVMAttributeEval

List of usage examples for weka.attributeSelection SVMAttributeEval SVMAttributeEval

Introduction

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

Prototype

public SVMAttributeEval() 

Source Link

Document

Constructor

Usage

From source file:ca.uottawa.balie.WekaAttributeSelection.java

License:Open Source License

/**
 * Select the top attributes/* w w w . j a  va2  s .c  o  m*/
 */
public void Select(boolean pi_Debug) {
    Instances insts = m_DummyLearner.GetTrainInstances();

    try {
        ASEvaluation eval = null;
        ASSearch search = null;

        if (m_Evaluator == WEKA_CHI_SQUARE) {
            eval = new ChiSquaredAttributeEval();
            search = new Ranker();
            ((Ranker) search).setNumToSelect(m_NumAttributes);
        } else if (m_Evaluator == WEKA_INFO_GAIN) {
            eval = new InfoGainAttributeEval();
            search = new Ranker();
            ((Ranker) search).setNumToSelect(m_NumAttributes);
        } else if (m_Evaluator == WEKA_WRAPPER) {
            eval = new ClassifierSubsetEval();
            ((ClassifierSubsetEval) eval).setClassifier(new NaiveBayes());
            search = new Ranker(); // TODO: use something else than ranker
            ((Ranker) search).setNumToSelect(m_NumAttributes);
        } else if (m_Evaluator == WEKA_SYM_UNCERT) {
            eval = new SymmetricalUncertAttributeEval();
            search = new Ranker();
            ((Ranker) search).setNumToSelect(m_NumAttributes);
        } else if (m_Evaluator == WEKA_SVM) {
            eval = new SVMAttributeEval();
            search = new Ranker();
            ((Ranker) search).setNumToSelect(m_NumAttributes);
        } else if (m_Evaluator == WEKA_RELIEF) {
            eval = new ReliefFAttributeEval();
            search = new Ranker();
            ((Ranker) search).setNumToSelect(m_NumAttributes);
        } else if (m_Evaluator == WEKA_ONER) {
            eval = new OneRAttributeEval();
            search = new Ranker();
            ((Ranker) search).setNumToSelect(m_NumAttributes);
        }

        m_AttributeSelection = new AttributeSelection();
        m_AttributeSelection.setEvaluator(eval);
        m_AttributeSelection.setSearch(search);

        m_AttributeSelection.SelectAttributes(insts);
        if (pi_Debug)
            System.out.println(m_AttributeSelection.toResultsString());

    } catch (Exception e) {
        System.err.println(e.getMessage());
    }

}