Skip to content

Instantly share code, notes, and snippets.

@renaud
Created February 7, 2014 08:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renaud/8858885 to your computer and use it in GitHub Desktop.
Save renaud/8858885 to your computer and use it in GitHub Desktop.
evaluate Mallet CRF
cc.mallet.types.InstanceList.CrossValidationIterator crossValidationIt = trainingInstanceList.crossValidationIterator(folds, new Random().nextInt());
while (crossValidationIt.hasNext()) {
InstanceList[] il = crossValidationIt.nextSplit();
CRF crf = new CRF(trainingInstanceList.getPipe(), null);
CRFTrainerByThreadedLabelLikelihood trainer = new CRFTrainerByThreadedLabelLikelihood(crf, threads);
// CRFTrainerByLabelLikelihood trainer = new CRFTrainerByLabelLikelihood(crf);
MultiSegmentationEvaluator eval = new MyMultiSegmentationEvaluator(//
new InstanceList[] { testingSet }, new String[] { "TTesting" }, tags, continueTags);
trainer.addEvaluator(eval);
trainer.train(trainingSet);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment