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


Java Instance.getDataAlphabet方法代码示例

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


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

示例1: makeList

import cc.mallet.types.Instance; //导入方法依赖的package包/类
/**
 *
 * @param i
 * @param j
 * @return A new {@link InstanceList} containing the two argument {@link Instance}s.
 */
public static InstanceList makeList (Instance i, Instance j) {
	InstanceList list = new InstanceList(new Noop(i.getDataAlphabet(), i.getTargetAlphabet()));
	list.add(i);
	list.add(j);
	return list;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:13,代码来源:ClusterUtils.java

示例2: setup

import cc.mallet.types.Instance; //导入方法依赖的package包/类
private void setup (InstanceList instances, Instance instance) {
	assert (instances != null || instance != null);
	if (instance == null && instances != null)
		instance = instances.get(0);
	// Initialize the alphabets
	if (dataAlphabet == null) {
		this.dataAlphabet = instance.getDataAlphabet();
		this.targetAlphabet = instance.getTargetAlphabet();
	}	else if (!Alphabet.alphabetsMatch(instance, this))
		// Make sure the alphabets match 
		throw new IllegalArgumentException ("Training set alphabets do not match those of NaiveBayesTrainer.");

	// Initialize or check the instancePipe
	if (instances != null) {
		if (instancePipe == null)
			instancePipe = instances.getPipe();
		else if (instancePipe != instances.getPipe())
			// Make sure that this pipes match.  Is this really necessary??  
			// I don't think so, but it could be confusing to have each returned classifier have a different pipe?  -akm 1/08
			throw new IllegalArgumentException ("Training set pipe does not match that of NaiveBayesTrainer.");
	}
	
	if (me == null) {
		int numLabels = targetAlphabet.size();
		me = new Multinomial.Estimator[numLabels];
		for (int i = 0; i < numLabels; i++) {
			me[i] = (Multinomial.Estimator) featureEstimator.clone();
			me[i].setAlphabet(dataAlphabet);
		}
		pe = (Multinomial.Estimator) priorEstimator.clone();
	}
	
  if (targetAlphabet.size() > me.length) {
    // target alphabet grew. increase size of our multinomial array
    int targetAlphabetSize = targetAlphabet.size();
    // copy over old values
    Multinomial.Estimator[] newMe = new Multinomial.Estimator[targetAlphabetSize];
    System.arraycopy (me, 0, newMe, 0, me.length);
    // initialize new expanded space
    for (int i= me.length; i<targetAlphabetSize; i++){
      Multinomial.Estimator mest = (Multinomial.Estimator)featureEstimator.clone ();
      mest.setAlphabet (dataAlphabet);
      newMe[i] = mest;
    }
    me = newMe;
  }
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:48,代码来源:NaiveBayesTrainer.java


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