当前位置: 首页>>代码示例>>Java>>正文


Java NBLinearClassifierFactory类代码示例

本文整理汇总了Java中edu.stanford.nlp.classify.NBLinearClassifierFactory的典型用法代码示例。如果您正苦于以下问题:Java NBLinearClassifierFactory类的具体用法?Java NBLinearClassifierFactory怎么用?Java NBLinearClassifierFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NBLinearClassifierFactory类属于edu.stanford.nlp.classify包,在下文中一共展示了NBLinearClassifierFactory类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: trainMaxEnt

import edu.stanford.nlp.classify.NBLinearClassifierFactory; //导入依赖的package包/类
private void trainMaxEnt(Dataset<String, String> train) {
  int prior = LogPrior.LogPriorType.QUADRATIC.ordinal();
  if (flags.useHuber) {
    prior = LogPrior.LogPriorType.HUBER.ordinal();
  } else if (flags.useQuartic) {
    prior = LogPrior.LogPriorType.QUARTIC.ordinal();
  }

  LinearClassifier<String, String> lc;
  if (flags.useNB) {
    lc = new NBLinearClassifierFactory<String, String>(flags.sigma).trainClassifier(train);
  } else {
    LinearClassifierFactory<String, String> lcf = new LinearClassifierFactory<String, String>(flags.tolerance, flags.useSum, prior, flags.sigma, flags.epsilon, flags.QNsize);
    if (flags.useQN) {
      lcf.useQuasiNewton(flags.useRobustQN);
    } else if(flags.useStochasticQN) {
      lcf.useStochasticQN(flags.initialGain,flags.stochasticBatchSize);
    } else if(flags.useSMD) {
      lcf.useStochasticMetaDescent(flags.initialGain, flags.stochasticBatchSize,flags.stochasticMethod,flags.SGDPasses);
    } else if(flags.useSGD) {
      lcf.useStochasticGradientDescent(flags.gainSGD,flags.stochasticBatchSize);
    } else if(flags.useSGDtoQN) {
      lcf.useStochasticGradientDescentToQuasiNewton(flags.initialGain, flags.stochasticBatchSize,
                                     flags.SGDPasses, flags.QNPasses, flags.SGD2QNhessSamples,
                                     flags.QNsize, flags.outputIterationsToFile);
    } else if(flags.useHybrid) {
      lcf.useHybridMinimizer(flags.initialGain, flags.stochasticBatchSize ,flags.stochasticMethod ,flags.hybridCutoffIteration );
    } else {
      lcf.useConjugateGradientAscent();
    }
    lc = lcf.trainClassifier(train);
  }
  this.classifier = lc;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:35,代码来源:CMMClassifier.java


注:本文中的edu.stanford.nlp.classify.NBLinearClassifierFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。