List of usage examples for weka.classifiers.evaluation Evaluation crossValidateModel
public void crossValidateModel(Classifier classifier, Instances data, int numFolds, Random random) throws Exception
From source file:gate.plugin.learningframework.engines.EngineWeka.java
@Override public Object evaluateXVal(InstanceList instances, int k, String parms) { Parms opts = new Parms(parms, "s:seed:i", "S:nostratify:b"); int seed = (int) opts.getValueOrElse("seed", 0); boolean noStratify = (boolean) opts.getValueOrElse("nostratify", 0); Random rand = new Random(seed); Instances all = new CorpusRepresentationWeka(corpusRepresentationMallet).getRepresentationWeka(); Evaluation eval = null; try {/*from w ww . j a v a 2s.co m*/ eval = new Evaluation(all); } catch (Exception ex) { throw new GateRuntimeException("Could not create evaluation object", ex); } Classifier classifier = (Classifier) trainer; try { eval.crossValidateModel(classifier, all, k, rand); } catch (Exception ex) { throw new GateRuntimeException("Error running cross validation", ex); } System.out.println("Crossvaliation evaluation result:\n" + eval); return eval; }