Example usage for weka.classifiers.rules JRip distributionForInstance

List of usage examples for weka.classifiers.rules JRip distributionForInstance

Introduction

In this page you can find the example usage for weka.classifiers.rules JRip distributionForInstance.

Prototype

@Override
public double[] distributionForInstance(Instance datum) 

Source Link

Document

Classify the test instance with the rule learner and provide the class distributions

Usage

From source file:br.com.edu.partition.Tranning.java

public static Double Tranning_JRIP(String test, String tranning) throws IOException, Exception {
    Double result_ = null;/* w  w  w .j ava 2 s.c om*/
    ArffLoader loader;
    loader = new ArffLoader();
    loader.setFile(new File(tranning));
    loader.getStructure();

    Instances trainingset = loader.getDataSet();
    int classIndex = trainingset.numAttributes() - 1;
    trainingset.setClassIndex(classIndex);

    //J48 j48 = new J48();
    JRip jRip = new JRip();
    //String[] options2 = {"-F", "3", "-N", "2.0", "-O", "2", "-S", "1"};
    //jRip.setOptions(options2);
    //jRip.buildClassifier(trainingset);
    jRip.buildClassifier(trainingset);

    loader = new ArffLoader();
    loader.setFile(new File(test));
    loader.getStructure();

    Instances testset = loader.getDataSet();
    testset.setClassIndex(testset.numAttributes() - 1);
    for (Instance instance : testset) {
        //double[] result = jRip.distributionForInstance(instance);
        double[] result = jRip.distributionForInstance(instance);
        result_ = result[1];
        //System.out.println(test + " " + result[1] + " " + tranning);
    }
    return result_;

}