Example usage for weka.classifiers Evaluation evaluationForSingleInstance

List of usage examples for weka.classifiers Evaluation evaluationForSingleInstance

Introduction

In this page you can find the example usage for weka.classifiers Evaluation evaluationForSingleInstance.

Prototype

public double evaluationForSingleInstance(double[] dist, Instance instance, boolean storePredictions)
        throws Exception 

Source Link

Document

Evaluates the supplied distribution on a single instance.

Usage

From source file:net.sf.jclal.classifier.WekaComitteClassifier.java

License:Open Source License

/**
 * Evaluates the classifier using the test dataset
 *
 * @param instances The test instances./*from www  .ja  v  a  2 s.  co  m*/
 * @return The evaluation of the model.
 */
@Override
public AbstractEvaluation testModel(IDataset instances) {

    try {

        // test phase with the actual model
        Evaluation evaluator;

        evaluator = new Evaluation(new Instances(instances.getDataset(), 0));

        Instances testData = instances.getDataset();

        for (Instance in : testData) {

            double temp[] = distributionForInstance(in);

            evaluator.evaluationForSingleInstance(temp, in, true);

        }

        SingleLabelEvaluation sleval = new SingleLabelEvaluation();

        sleval.setEvaluation(evaluator);

        return sleval;

    } catch (Exception e) {
        Logger.getLogger(WekaComitteClassifier.class.getName()).log(Level.SEVERE, null, e);
    }

    return null;
}