朴素贝叶斯分类器截止

时间:2017-11-30 10:05:54

标签: java machine-learning classification 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/classifierA.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, 3+"");
    params.put(AbstractTrainer.ALGORITHM_PARAM, NaiveBayesTrainer.NAIVE_BAYES_VALUE);

    // create a model from traning data
    DoccatModel model = DocumentCategorizerME.train("NL", sampleStream, params, new DoccatFactory());

    OutputStream modelOut = null;
    modelOut = new BufferedOutputStream(new FileOutputStream("src/main/resources/models/model.bin"));
    model.serialize(modelOut);

    return model;
}

任何人都可以解释以下代码在培训进度中的作用:

params.put(TrainingParameters.CUTOFF_PARAM, 3+"");

提前致谢!

0 个答案:

没有答案