Example usage for weka.classifiers.trees RandomForest setSeed

List of usage examples for weka.classifiers.trees RandomForest setSeed

Introduction

In this page you can find the example usage for weka.classifiers.trees RandomForest setSeed.

Prototype

public void setSeed(int s) 

Source Link

Document

Sets the seed for the random number generator.

Usage

From source file:predictors.HelixIndexer.java

License:Open Source License

/**
 * Trains the Weka Classifer.//from   w w  w.java2 s.c o  m
 */
public void trainClassifier() {
    try {
        RandomForest classifier = new weka.classifiers.trees.RandomForest();
        Instances data = this.dataset;

        if (data.classIndex() == -1) {
            data.setClassIndex(data.numAttributes() - 1);
        }

        data.randomize(new Random(data.size()));

        String[] optClassifier = weka.core.Utils.splitOptions("-I 100 -K 9 -S 1 -num-slots 3");

        classifier.setOptions(optClassifier);
        classifier.setSeed(data.size());

        classifier.buildClassifier(data);

        this.classifier = classifier;
        this.isTrained = true;
    } catch (Exception e) {
        ErrorUtils.printError(HelixIndexer.class, "Training failed", e);
    }
}

From source file:predictors.TopologyPredictor.java

License:Open Source License

/**
 * Trains the Weka Classifer./*w ww  .  java  2 s. c om*/
 */
public void trainClassifier() {
    try {
        RandomForest classifier = new weka.classifiers.trees.RandomForest();
        Instances data = this.dataset;

        if (data.classIndex() == -1) {
            data.setClassIndex(data.numAttributes() - 1);
        }

        data.randomize(new Random(data.size()));

        String[] optClassifier = weka.core.Utils.splitOptions("-I 100 -K 7 -S 1 -num-slots 1");

        classifier.setOptions(optClassifier);
        classifier.setSeed(data.size());

        classifier.buildClassifier(data);

        this.classifier = classifier;
        this.isTrained = true;
    } catch (Exception e) {
        ErrorUtils.printError(TopologyPredictor.class, "Training failed", e);
    }
}