本文整理汇总了Java中cc.mallet.pipe.iterator.RandomTokenSequenceIterator类的典型用法代码示例。如果您正苦于以下问题:Java RandomTokenSequenceIterator类的具体用法?Java RandomTokenSequenceIterator怎么用?Java RandomTokenSequenceIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RandomTokenSequenceIterator类属于cc.mallet.pipe.iterator包,在下文中一共展示了RandomTokenSequenceIterator类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: InstanceList
import cc.mallet.pipe.iterator.RandomTokenSequenceIterator; //导入依赖的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: testRandomTrainedOn
import cc.mallet.pipe.iterator.RandomTokenSequenceIterator; //导入依赖的package包/类
private double testRandomTrainedOn (InstanceList training)
{
ClassifierTrainer trainer = new MaxEntTrainer ();
Alphabet fd = dictOfSize (3);
String[] classNames = new String[] {"class0", "class1", "class2"};
Randoms r = new Randoms (1);
Iterator<Instance> iter = new RandomTokenSequenceIterator (r, new Dirichlet(fd, 2.0),
30, 0, 10, 200, classNames);
training.addThruPipe (iter);
InstanceList testing = new InstanceList (training.getPipe ());
testing.addThruPipe (new RandomTokenSequenceIterator (r, new Dirichlet(fd, 2.0),
30, 0, 10, 200, classNames));
System.out.println ("Training set size = "+training.size());
System.out.println ("Testing set size = "+testing.size());
Classifier classifier = trainer.train (training);
System.out.println ("Accuracy on training set:");
System.out.println (classifier.getClass().getName()
+ ": " + new Trial (classifier, training).getAccuracy());
System.out.println ("Accuracy on testing set:");
double testAcc = new Trial (classifier, testing).getAccuracy();
System.out.println (classifier.getClass().getName()
+ ": " + testAcc);
return testAcc;
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:33,代码来源:TestPagedInstanceList.java
示例3: testNewFeatures
import cc.mallet.pipe.iterator.RandomTokenSequenceIterator; //导入依赖的package包/类
public void testNewFeatures ()
{
ClassifierTrainer[] trainers = new ClassifierTrainer[1];
trainers[0] = new MaxEntTrainer();
Alphabet fd = dictOfSize (3);
String[] classNames = new String[] {"class0", "class1", "class2"};
Randoms r = new Randoms(1);
InstanceList training = new InstanceList (r, fd, classNames, 50);
expandDict (fd, 25);
Classifier[] classifiers = new Classifier[trainers.length];
for (int i = 0; i < trainers.length; i++)
classifiers[i] = trainers[i].train (training);
System.out.println ("Accuracy on training set:");
for (int i = 0; i < trainers.length; i++)
System.out.println (classifiers[i].getClass().getName()
+ ": " + new Trial (classifiers[i], training).getAccuracy());
InstanceList testing = new InstanceList (training.getPipe ());
Iterator<Instance> iter = new RandomTokenSequenceIterator (
r, new Dirichlet (fd, 2.0),
30, 0,
10, 50,
classNames);
testing.addThruPipe (iter);
for (int i = 0; i < testing.size (); i++) {
Instance inst = testing.get (i);
System.out.println ("DATA:"+inst.getData());
}
System.out.println ("Accuracy on testing set:");
for (int i = 0; i < trainers.length; i++)
System.out.println (classifiers[i].getClass().getName()
+ ": " + new Trial (classifiers[i], testing).getAccuracy());
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:40,代码来源:TestClassifiers.java
示例4: testRandomTrainedOn
import cc.mallet.pipe.iterator.RandomTokenSequenceIterator; //导入依赖的package包/类
private double testRandomTrainedOn (InstanceList training)
{
ClassifierTrainer trainer = new MaxEntTrainer();
Alphabet fd = dictOfSize (3);
String[] classNames = new String[] {"class0", "class1", "class2"};
Randoms r = new Randoms (1);
Iterator<Instance> iter = new RandomTokenSequenceIterator (r, new Dirichlet(fd, 2.0),
30, 0, 10, 200, classNames);
training.addThruPipe (iter);
InstanceList testing = new InstanceList (training.getPipe ());
testing.addThruPipe (new RandomTokenSequenceIterator (r, new Dirichlet(fd, 2.0),
30, 0, 10, 200, classNames));
System.out.println ("Training set size = "+training.size());
System.out.println ("Testing set size = "+testing.size());
Classifier classifier = trainer.train (training);
System.out.println ("Accuracy on training set:");
System.out.println (classifier.getClass().getName()
+ ": " + new Trial(classifier, training).getAccuracy());
System.out.println ("Accuracy on testing set:");
double testAcc = new Trial (classifier, testing).getAccuracy();
System.out.println (classifier.getClass().getName()
+ ": " + testAcc);
return testAcc;
}
开发者ID:mimno,项目名称:Mallet,代码行数:33,代码来源:TestPagedInstanceList.java
注:本文中的cc.mallet.pipe.iterator.RandomTokenSequenceIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论