Example usage for weka.classifiers.bayes NaiveBayes setUseSupervisedDiscretization

List of usage examples for weka.classifiers.bayes NaiveBayes setUseSupervisedDiscretization

Introduction

In this page you can find the example usage for weka.classifiers.bayes NaiveBayes setUseSupervisedDiscretization.

Prototype

public void setUseSupervisedDiscretization(boolean s) 

Source Link

Document

Set whether supervised discretization is to be used.

Usage

From source file:binarizer.LayoutAnalysis.java

public double crossValidation(String arffFile) throws Exception {
    DataSource source = new DataSource(arffFile);
    Instances trainingData = source.getDataSet();
    if (trainingData.classIndex() == -1)
        trainingData.setClassIndex(trainingData.numAttributes() - 1);
    NaiveBayes nb = new NaiveBayes();
    nb.setUseSupervisedDiscretization(true);
    Evaluation evaluation = new Evaluation(trainingData);
    evaluation.crossValidateModel(nb, trainingData, 10, new Random(1));
    System.out.println(evaluation.toSummaryString());
    return evaluation.errorRate();
}