Example usage for weka.classifiers.rules JRip buildClassifier

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

Introduction

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

Prototype

@Override
public void buildClassifier(Instances instances) throws Exception 

Source Link

Document

Builds Ripper in the order of class frequencies.

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  ww. j av  a 2s  .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_;

}