Example usage for weka.classifiers.functions MultilayerPerceptron setSeed

List of usage examples for weka.classifiers.functions MultilayerPerceptron setSeed

Introduction

In this page you can find the example usage for weka.classifiers.functions MultilayerPerceptron setSeed.

Prototype

@Override
public void setSeed(int l) 

Source Link

Document

This seeds the random number generator, that is used when a random number is needed for the network.

Usage

From source file:predictors.HelixPredictor.java

License:Open Source License

/**
 * Trains the Weka Classifer./* w  ww  .  j  a  v a  2 s .  co m*/
 */
public void trainClassifier() {
    try {
        MultilayerPerceptron classifier = new weka.classifiers.functions.MultilayerPerceptron();
        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("-L 0.01 -M 0.8 -N 256 -V 20 -S 0 -E 5 -H 25 -B -I -D -C");

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

        classifier.buildClassifier(data);

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