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


Java LabelAlphabet.lookupIndex方法代码示例

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


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

示例1: testReadResolve

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
/** Tests how serializing labels separately can lead to big losses.
 *   This currently fails.  I'm not sure what to do about this. -cas
 */
public void testReadResolve () throws IOException, ClassNotFoundException
{
  LabelAlphabet dict = new LabelAlphabet ();
  dict.lookupIndex ("TEST1");
  dict.lookupIndex ("TEST2");
  dict.lookupIndex ("TEST3");


  Label t1 = dict.lookupLabel ("TEST1");
  Labelee l = new Labelee (dict, t1);
  Labelee l2 = (Labelee) TestSerializable.cloneViaSerialization (l);

  assertTrue (l.dict == l2.dict);
  assertTrue (dict.lookupLabel("TEST1") == l.theLabel);
  assertTrue (dict.lookupLabel("TEST1") == l2.theLabel);
  assertTrue (l.theLabel == l2.theLabel);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:21,代码来源:TestLabelAlphabet.java

示例2: createLabelVector

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
/** Constructs a LabelVector which is a distribution over indices of
 * the "positive" Instance. */
private LabelVector createLabelVector (LabelAlphabet labelAlphabet, double[] scores) {
	if (labelAlphabet.growthStopped())
		labelAlphabet.startGrowth();
	
	for (int i=0; i < scores.length; i++) 
		labelAlphabet.lookupIndex(String.valueOf(i), true);

	double[] allScores = new double[labelAlphabet.size()];

	for (int i=0; i < labelAlphabet.size(); i++) 
		allScores[i] = 0.0;

	for (int i=0; i < scores.length; i++) {
		int index = labelAlphabet.lookupIndex(String.valueOf(i), true);
		allScores[index] = scores[i];
	}
	return new LabelVector(labelAlphabet, allScores);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:21,代码来源:RankMaxEnt.java

示例3: init

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
private void init() {
    svmLabel2mltLabel = new HashMap<Double, String>();
    for (Entry<String, Double> entry : mltLabel2svmLabel.entrySet()) {
        svmLabel2mltLabel.put(entry.getValue(), entry.getKey());
    }

    svmIndex2mltIndex = new int[model.nr_class + 1];
    int[] sLabels = model.label;
    LabelAlphabet labelAlphabet = getLabelAlphabet();
    for (int sIndex = 0; sIndex < sLabels.length; sIndex++) {
        double sLabel = sLabels[sIndex];
        String mLabel = svmLabel2mltLabel.get(sLabel * 1.0);
        int mIndex = labelAlphabet.lookupIndex(mLabel.toString(), false);
        svmIndex2mltIndex[sIndex] = mIndex;
    }
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:17,代码来源:SVMClassifier.java

示例4: ignoretestReadResolve

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
/** Tests how serializing labels separately can lead to big losses.
 *   This currently fails.  I'm not sure what to do about this. -cas
 */
public void ignoretestReadResolve () throws IOException, ClassNotFoundException
{
  LabelAlphabet dict = new LabelAlphabet ();
  dict.lookupIndex ("TEST1");
  dict.lookupIndex ("TEST2");
  dict.lookupIndex ("TEST3");


  Label t1 = dict.lookupLabel ("TEST1");
  Labelee l = new Labelee (dict, t1);
  Labelee l2 = (Labelee) TestSerializable.cloneViaSerialization (l);

  assertTrue (l.dict == l2.dict);
  assertTrue (dict.lookupLabel("TEST1") == l.theLabel);
  assertTrue (dict.lookupLabel("TEST1") == l2.theLabel);
  assertTrue (l.theLabel == l2.theLabel);
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:21,代码来源:TestLabelAlphabet.java

示例5: createBlankAlphabet

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
private static LabelAlphabet createBlankAlphabet (int numOutcomes)
{
  if (numOutcomes > 0) {
    LabelAlphabet outcomes = new LabelAlphabet ();
    /* Setup default outcomes */
    for (int i = 0; i < numOutcomes; i++) {
      outcomes.lookupIndex (new Integer (i));
    }
    return outcomes;
  } else return null;
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:12,代码来源:Variable.java

示例6: setUp

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
protected void setUp ()
{
	ld = new LabelAlphabet ();
	lv = new LabelVector (ld,
												new int[] {
													ld.lookupIndex ("a"),
													ld.lookupIndex ("b"),
													ld.lookupIndex ("c"),
													ld.lookupIndex ("d")},
												new double[] {3, 4, 2, 1});
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:12,代码来源:TestLabelVector.java

示例7: trainAll

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
public void trainAll(ListDataSet dataSet) {
	Matrix dataSetInput = dataSet.getInputMatrix();

	Matrix max = dataSetInput.max(Ret.NEW, Matrix.ROW);
	cumSum = new ArrayList<Integer>((int) max.getColumnCount());
	int sum = 0;
	cumSum.add(sum);
	for (int i = (int) max.getColumnCount() - 1; i != -1; i--) {
		sum += max.getAsInt(0, i) + 1;
		cumSum.add(sum);
	}

	LabelAlphabet inputAlphabet = new LabelAlphabet();
	int featureCount = getFeatureCount(dataSet);
	for (int i = 0; i < featureCount; i++) {
		// iterate from 1 to max (inclusive!)
		for (int fv = 1; fv < max.getAsDouble(0, i) + 1; fv++) {
			inputAlphabet.lookupIndex("Feature" + i + "=" + fv, true);
		}
	}

	LabelAlphabet targetAlphabet = new LabelAlphabet();
	for (int i = 0; i < dataSet.getTargetMatrix().getColumnCount(); i++) {
		targetAlphabet.lookupIndex("Class" + i, true);
	}

	InstanceList trainingSet = new DataSet2InstanceList(dataSet, inputAlphabet, targetAlphabet, cumSum);

	classifier = trainer.train(trainingSet);
}
 
开发者ID:jdmp,项目名称:java-data-mining-package,代码行数:31,代码来源:MalletClassifier.java


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