【发布时间】:2018-05-05 20:59:56
【问题描述】:
我目前正在为分类器训练模型。昨天我发现如果你也测试创建的分类模型会更准确。我尝试在互联网上搜索如何测试模型:testing openNLP model。但我无法让它工作。我认为原因是因为我使用的是 OpenNLP 版本 1.83 而不是 1.5。谁能解释我如何在这个版本的 OpenNLP 中正确测试我的模型?
提前致谢。
以下是我训练我的模型的方式:
public static DoccatModel trainClassifier() throws IOException
{
// read the training data
final int iterations = 100;
InputStreamFactory dataIn = new MarkableFileInputStreamFactory(new File("src/main/resources/trainingSets/trainingssetTest.txt"));
ObjectStream<String> lineStream = new PlainTextByLineStream(dataIn, "UTF-8");
ObjectStream<DocumentSample> sampleStream = new DocumentSampleStream(lineStream);
// define the training parameters
TrainingParameters params = new TrainingParameters();
params.put(TrainingParameters.ITERATIONS_PARAM, iterations+"");
params.put(TrainingParameters.CUTOFF_PARAM, 0+"");
params.put(AbstractTrainer.ALGORITHM_PARAM, NaiveBayesTrainer.NAIVE_BAYES_VALUE);
// create a model from traning data
DoccatModel model = DocumentCategorizerME.train("NL", sampleStream, params, new DoccatFactory());
return model;
}
【问题讨论】:
标签: java classification training-data opennlp