Example usage for weka.attributeSelection GeneticSearch setSeed

List of usage examples for weka.attributeSelection GeneticSearch setSeed

Introduction

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

Prototype

public void setSeed(int s) 

Source Link

Document

set the seed for random number generation

Usage

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

public double startBlackBox(Problema p) {
    try {//w ww .j av a2  s . c  o  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;
}