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


Java FeatureSequence2FeatureVector类代码示例

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


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

示例1: InstanceList

import cc.mallet.pipe.FeatureSequence2FeatureVector; //导入依赖的package包/类
/**
 * Creates a list consisting of randomly-generated
 * <code>FeatureVector</code>s.
 */
// xxx Perhaps split these out into a utility class
public InstanceList (Randoms r,
                     // the generator of all random-ness used here
                     Dirichlet classCentroidDistribution,
                     // includes a Alphabet
                     double classCentroidAverageAlphaMean,
                     // Gaussian mean on the sum of alphas
                     double classCentroidAverageAlphaVariance,
                     // Gaussian variance on the sum of alphas
                     double featureVectorSizePoissonLambda,
                     double classInstanceCountPoissonLambda,
                     String[] classNames)
{
	this (new SerialPipes (new Pipe[]	{
			new TokenSequence2FeatureSequence (),
			new FeatureSequence2FeatureVector (),
			new Target2Label()}));
	//classCentroidDistribution.print();
	Iterator<Instance> iter = new RandomTokenSequenceIterator (
			r, classCentroidDistribution,
			classCentroidAverageAlphaMean, classCentroidAverageAlphaVariance,
			featureVectorSizePoissonLambda, classInstanceCountPoissonLambda,
			classNames);
	this.addThruPipe (iter);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:30,代码来源:InstanceList.java

示例2: main

import cc.mallet.pipe.FeatureSequence2FeatureVector; //导入依赖的package包/类
public static void main(String[] args) throws IOException, Exception {
    ArrayList<Pipe> pipes = new ArrayList<Pipe>();
    pipes.add(new Target2Label());
    pipes.add(new CharSequence2TokenSequence());
    pipes.add(new TokenSequence2FeatureSequence());
    pipes.add(new FeatureSequence2FeatureVector());
    SerialPipes pipe = new SerialPipes(pipes);

    //prepare training instances
    InstanceList trainingInstanceList = new InstanceList(pipe);
    trainingInstanceList.addThruPipe(new CsvIterator(new FileReader("webkb-train-stemmed.txt"),
            "(.*)\t(.*)", 2, 1, -1));

    //prepare test instances
    InstanceList testingInstanceList = new InstanceList(pipe);
    testingInstanceList.addThruPipe(new CsvIterator(new FileReader("webkb-test-stemmed.txt"),
            "(.*)\t(.*)", 2, 1, -1));

    ClassifierTrainer trainer = new SVMClassifierTrainer(new LinearKernel());
    Classifier classifier = trainer.train(trainingInstanceList);
    System.out.println("Accuracy: " + classifier.getAccuracy(testingInstanceList));

}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:24,代码来源:Main.java

示例3: testRandomTrained

import cc.mallet.pipe.FeatureSequence2FeatureVector; //导入依赖的package包/类
public void testRandomTrained ()
{
  Pipe p = new SerialPipes(new Pipe[]	{
	new TokenSequence2FeatureSequence(),
	new FeatureSequence2FeatureVector(),
	new Target2Label()});

  double testAcc1 = testRandomTrainedOn (new InstanceList (p));
  double testAcc2 = testRandomTrainedOn (new PagedInstanceList (p, 700, 200, new File(".")));
  assertEquals (testAcc1, testAcc2, 0.01);
}
 
开发者ID:mimno,项目名称:Mallet,代码行数:12,代码来源:TestPagedInstanceList.java

示例4: testThree

import cc.mallet.pipe.FeatureSequence2FeatureVector; //导入依赖的package包/类
public void testThree ()
{
	InstanceList il = new InstanceList (
		new SerialPipes(new Pipe[] {
			new Target2Label(),
			new CharSequence2TokenSequence(),
			new TokenSequenceLowercase(),
			new TokenSequenceRemoveStopwords(),
			new TokenSequence2FeatureSequence(),
			new FeatureSequence2FeatureVector()
		}));
	Iterator<Instance> pi = new FileIterator(new File("foo/bar"), null, Pattern.compile("^([^/]*)/"));
	il.addThruPipe (pi);
}
 
开发者ID:mimno,项目名称:Mallet,代码行数:15,代码来源:TestRainbowStyle.java

示例5: createPipe

import cc.mallet.pipe.FeatureSequence2FeatureVector; //导入依赖的package包/类
public Pipe createPipe () {
	return new SerialPipes(new Pipe[] {
			 new CharSequence2TokenSequence(),
			 new TokenSequenceLowercase(),
			 new TokenSequence2FeatureSequence(),
			 new FeatureSequence2FeatureVector()});
}
 
开发者ID:mimno,项目名称:Mallet,代码行数:8,代码来源:TestInstancePipe.java

示例6: getPipes

import cc.mallet.pipe.FeatureSequence2FeatureVector; //导入依赖的package包/类
static List<Pipe> getPipes() {

        List<Pipe> pipes = newArrayList();
        pipes.add(new Target2Label());
        pipes.add(new MyInput2RegexTokens());

        // pipes.add(new PrintInputAndTarget());

        pipes.add(new TokenSequence2FeatureSequence());
        pipes.add(new FeatureSequence2FeatureVector());
        return pipes;
    }
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:13,代码来源:ReferencesClassifierTrainer.java

示例7: buildPipe

import cc.mallet.pipe.FeatureSequence2FeatureVector; //导入依赖的package包/类
public Pipe buildPipe() {
    ArrayList pipeList = new ArrayList();

    // Read data from File objects
    pipeList.add(new Input2CharSequence("UTF-8"));

    // Regular expression for what constitutes a token.
    //  This pattern includes Unicode letters, Unicode numbers, 
    //   and the underscore character. Alternatives:
    //    "\\S+"   (anything not whitespace)
    //    "\\w+"    ( A-Z, a-z, 0-9, _ )
    //    "[\\p{L}\\p{N}_]+|[\\p{P}]+"   (a group of only letters and numbers OR
    //                                    a group of only punctuation marks)
    Pattern tokenPattern =
        Pattern.compile("[\\p{L}\\p{N}_]+");

    // Tokenize raw strings
    pipeList.add(new CharSequence2TokenSequence(tokenPattern));

    // Normalize all tokens to all lowercase
    pipeList.add(new TokenSequenceLowercase());

    // Remove stopwords from a standard English stoplist.
    //  options: [case sensitive] [mark deletions]
    pipeList.add(new TokenSequenceRemoveStopwords(false, false));

    // Rather than storing tokens as strings, convert 
    //  them to integers by looking them up in an alphabet.
    pipeList.add(new TokenSequence2FeatureSequence());

    // Do the same thing for the "target" field: 
    //  convert a class label string to a Label object,
    //  which has an index in a Label alphabet.
    pipeList.add(new Target2Label());

    // Now convert the sequence of features to a sparse vector,
    //  mapping feature IDs to counts.
    pipeList.add(new FeatureSequence2FeatureVector());

    // Print out the features and the label
    //pipeList.add(new PrintInputAndTarget());

    return new SerialPipes(pipeList);
}
 
开发者ID:guanxin0520,项目名称:dhnowFilter,代码行数:45,代码来源:EvaluateClassifier.java


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