Example usage for weka.classifiers.trees HoeffdingTree distributionForInstance

List of usage examples for weka.classifiers.trees HoeffdingTree distributionForInstance

Introduction

In this page you can find the example usage for weka.classifiers.trees HoeffdingTree distributionForInstance.

Prototype

@Override
public double[] distributionForInstance(Instance inst) throws Exception 

Source Link

Document

Returns class probabilities for an instance.

Usage

From source file:fcul.viegas.ml.learners.NetworkStreamLearningClassifierMapFunction.java

public InstanceStreamDTO map(InstanceStreamDTO instance) throws Exception {

    weka.core.Instance inst = instance.getInstance();
    inst.setDataset(this.coreInstances);
    inst.setClassValue(inst.classValue());
    inst = classifier.constructMappedInstance(inst);

    HoeffdingTree tree = (HoeffdingTree) classifier.getClassifier();
    double[] classe = tree.distributionForInstance(inst);
    instance.setInstance(null);// w w w  .  j  a v a  2  s . c  o m
    //System.out.println("\t classe[0]: " + classe[0] + " classe[1]: " + classe[1]);
    if (classe[0] > classe[1]) {
        instance.setAssignedClassValueFromLearner(0.0d);
    } else {
        instance.setAssignedClassValueFromLearner(1.0d);
    }
    return instance;
}