Example usage for weka.attributeSelection WrapperSubsetEval setClassifier

List of usage examples for weka.attributeSelection WrapperSubsetEval setClassifier

Introduction

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

Prototype

public void setClassifier(Classifier newClassifier) 

Source Link

Document

Set the classifier to use for accuracy estimation

Usage

From source file:trabfs.machineLeaningFrameWork.search.misc.BlackBox.java

public double startBlackBox(Problema p) {
    try {//from w ww  . j  a va2s.  co  m
        Random r = new Random();
        //cria avaliador de solucao
        AvaliadordeSolucao ads = new AvaliadordeSolucao(p);
        //seta busca            
        GeneticSearch gs = new GeneticSearch();
        gs.setSeed(r.nextInt());
        //seta evaluator
        WrapperSubsetEval wse = new WrapperSubsetEval();
        //seta classificador
        IBk ibk = new IBk(3);
        // seta selecao de atributos
        AttributeSelection as = new AttributeSelection();

        //liga componentes
        wse.setClassifier(ibk);
        as.setSearch(gs);
        as.setEvaluator(wse);

        //usa metodo e pega solucao
        Solucao s = new Solucao(p.getNumAtributos() - 1);
        s.initZero();
        as.SelectAttributes(p.getInstances());
        for (int i = 0; i < as.selectedAttributes().length - 1; i++) {
            s.set(as.selectedAttributes()[i], 1);
        }
        ads.avalia(s);
        return s.getQuality();

    } catch (Exception ex) {
        Logger.getLogger(BlackBox.class.getName()).log(Level.SEVERE, null, ex);
    }
    return 0.0;
}