Example usage for weka.attributeSelection GeneticSearch GeneticSearch

List of usage examples for weka.attributeSelection GeneticSearch GeneticSearch

Introduction

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

Prototype

public GeneticSearch() 

Source Link

Document

Constructor.

Usage

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

public double startBlackBox(Problema p) {
    try {/*w w  w.  j  a v  a 2  s. com*/
        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;
}