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


Java Labeling.indexAtLocation方法代码示例

本文整理汇总了Java中cc.mallet.types.Labeling.indexAtLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Labeling.indexAtLocation方法的具体用法?Java Labeling.indexAtLocation怎么用?Java Labeling.indexAtLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.mallet.types.Labeling的用法示例。


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

示例1: incorporateOneInstance

import cc.mallet.types.Labeling; //导入方法依赖的package包/类
private void incorporateOneInstance (Instance instance, double instanceWeight) 
{
  Labeling labeling = instance.getLabeling ();
  if (labeling == null) return; // Handle unlabeled instances by skipping them
  FeatureVector fv = (FeatureVector) instance.getData ();
  double oneNorm = fv.oneNorm();
  if (oneNorm <= 0) return; // Skip instances that have no features present
  if (docLengthNormalization > 0)
  	// Make the document have counts that sum to docLengthNormalization
  	// I.e., if 20, it would be as if the document had 20 words.
  	instanceWeight *= docLengthNormalization / oneNorm;
  assert (instanceWeight > 0 && !Double.isInfinite(instanceWeight));
  for (int lpos = 0; lpos < labeling.numLocations(); lpos++) {
    int li = labeling.indexAtLocation (lpos);
    double labelWeight = labeling.valueAtLocation (lpos);
    if (labelWeight == 0) continue;
    //System.out.println ("NaiveBayesTrainer me.increment "+ labelWeight * instanceWeight);
    me[li].increment (fv, labelWeight * instanceWeight);
    // This relies on labelWeight summing to 1 over all labels
    pe.increment (li, labelWeight * instanceWeight);
  }
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:23,代码来源:NaiveBayesTrainer.java


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