本文整理汇总了Java中cc.mallet.types.Multinomial类的典型用法代码示例。如果您正苦于以下问题:Java Multinomial类的具体用法?Java Multinomial怎么用?Java Multinomial使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Multinomial类属于cc.mallet.types包,在下文中一共展示了Multinomial类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createRandomChain
import cc.mallet.types.Multinomial; //导入依赖的package包/类
public static FactorGraph createRandomChain (cc.mallet.util.Randoms r, int length)
{
Variable[] vars = new Variable[length];
for (int i = 0; i < length; i++)
vars[i] = new Variable (2);
Dirichlet dirichlet = new Dirichlet (new double[] { 1, 1, 1, 1 });
FactorGraph mdl = new FactorGraph (vars);
for (int i = 0; i < length - 1; i++) {
Multinomial m = dirichlet.randomMultinomial (r);
double[] probs = m.getValues ();
mdl.addFactor (vars[i], vars[i + 1], probs);
}
return mdl;
}
开发者ID:mimno,项目名称:GRMM,代码行数:18,代码来源:RandomGraphs.java
示例2: reset
import cc.mallet.types.Multinomial; //导入依赖的package包/类
@Deprecated
public void reset() {
emissionEstimator = new Multinomial.LaplaceEstimator[numStates()];
transitionEstimator = new Multinomial.LaplaceEstimator[numStates()];
emissionMultinomial = new Multinomial[numStates()];
transitionMultinomial = new Multinomial[numStates()];
Alphabet transitionAlphabet = getTransitionAlphabet();
for (int i = 0; i < numStates(); i++) {
emissionEstimator[i] = new Multinomial.LaplaceEstimator(
inputAlphabet);
transitionEstimator[i] = new Multinomial.LaplaceEstimator(
transitionAlphabet);
emissionMultinomial[i] = new Multinomial(
getUniformArray(inputAlphabet.size()), inputAlphabet);
transitionMultinomial[i] = new Multinomial(
getUniformArray(transitionAlphabet.size()),
transitionAlphabet);
}
initialMultinomial = new Multinomial(getUniformArray(transitionAlphabet
.size()), transitionAlphabet);
initialEstimator = new Multinomial.LaplaceEstimator(transitionAlphabet);
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:23,代码来源:HMM.java
示例3: initTransitions
import cc.mallet.types.Multinomial; //导入依赖的package包/类
/**
* Separate initialization of initial/transitions and emissions. All
* probabilities are proportional to (1+Uniform[0,1])^noise.
*
* @author kedarb
* @param random
* Random object (if null use uniform distribution)
* @param noise
* Noise exponent to use. If zero, then uniform distribution.
*/
public void initTransitions(Random random, double noise) {
Alphabet transitionAlphabet = getTransitionAlphabet();
initialMultinomial = new Multinomial(getRandomArray(transitionAlphabet
.size(), random, noise), transitionAlphabet);
initialEstimator = new Multinomial.LaplaceEstimator(transitionAlphabet);
transitionMultinomial = new Multinomial[numStates()];
transitionEstimator = new Multinomial.LaplaceEstimator[numStates()];
for (int i = 0; i < numStates(); i++) {
transitionMultinomial[i] = new Multinomial(getRandomArray(
transitionAlphabet.size(), random, noise),
transitionAlphabet);
transitionEstimator[i] = new Multinomial.LaplaceEstimator(
transitionAlphabet);
// set state's initial weight
State s = (State) getState(i);
s.setInitialWeight(initialMultinomial.logProbability(s.getName()));
}
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:29,代码来源:HMM.java
示例4: estimate
import cc.mallet.types.Multinomial; //导入依赖的package包/类
public void estimate() {
Alphabet transitionAlphabet = getTransitionAlphabet();
initialMultinomial = initialEstimator.estimate();
initialEstimator = new Multinomial.LaplaceEstimator(transitionAlphabet);
for (int i = 0; i < numStates(); i++) {
State s = (State) getState(i);
emissionMultinomial[i] = emissionEstimator[i].estimate();
transitionMultinomial[i] = transitionEstimator[i].estimate();
s.setInitialWeight(initialMultinomial.logProbability(s.getName()));
// reset estimators
emissionEstimator[i] = new Multinomial.LaplaceEstimator(
inputAlphabet);
transitionEstimator[i] = new Multinomial.LaplaceEstimator(
transitionAlphabet);
}
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:17,代码来源:HMM.java
示例5: setTrainable
import cc.mallet.types.Multinomial; //导入依赖的package包/类
public void setTrainable (boolean f)
{
trainable = f;
if (f) {
// This wipes away any previous counts we had.
// It also potentially allocates an esimator of a new size if
// the number of states has increased.
initialStateCounts = new Multinomial.LaplaceEstimator (states.size());
finalStateCounts = new Multinomial.LaplaceEstimator (states.size());
} else {
initialStateCounts = null;
finalStateCounts = null;
}
for (int i = 0; i < numStates(); i++)
((State)getState(i)).setTrainable(f);
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:17,代码来源:FeatureTransducer.java
示例6: readObject
import cc.mallet.types.Multinomial; //导入依赖的package包/类
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
int version = in.readInt();
if (version != CURRENT_SERIAL_VERSION)
throw new ClassNotFoundException("Mismatched NaiveBayesTrainer versions: wanted " +
CURRENT_SERIAL_VERSION + ", got " +
version);
//default selections for the kind of Estimator used
featureEstimator = (Multinomial.Estimator) in.readObject();
priorEstimator = (Multinomial.Estimator) in.readObject();
// These are the counts formed after NaiveBayes training.
me = (Multinomial.Estimator []) in.readObject();
pe = (Multinomial.Estimator) in.readObject();
// pipe and alphabets
instancePipe = (Pipe) in.readObject();
dataAlphabet = (Alphabet) in.readObject();
targetAlphabet = (Alphabet) in.readObject();
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:21,代码来源:NaiveBayesTrainer.java
示例7: initEmissions
import cc.mallet.types.Multinomial; //导入依赖的package包/类
public void initEmissions(Random random, double noise) {
emissionMultinomial = new Multinomial[numStates()];
emissionEstimator = new Multinomial.LaplaceEstimator[numStates()];
for (int i = 0; i < numStates(); i++) {
emissionMultinomial[i] = new Multinomial(getRandomArray(
inputAlphabet.size(), random, noise), inputAlphabet);
emissionEstimator[i] = new Multinomial.LaplaceEstimator(
inputAlphabet);
}
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:11,代码来源:HMM.java
示例8: estimate
import cc.mallet.types.Multinomial; //导入依赖的package包/类
public void estimate ()
{
if (initialStateCounts == null || finalStateCounts == null)
throw new IllegalStateException ("This transducer not currently trainable.");
Multinomial initialStateDistribution = initialStateCounts.estimate ();
Multinomial finalStateDistribution = finalStateCounts.estimate ();
for (int i = 0; i < states.size(); i++) {
State s = states.get (i);
s.initialWeight = initialStateDistribution.logProbability (i);
s.finalWeight = finalStateDistribution.logProbability (i);
s.estimate ();
}
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:14,代码来源:FeatureTransducer.java
示例9: testIncrement
import cc.mallet.types.Multinomial; //导入依赖的package包/类
public void testIncrement ()
{
transducer.setTrainable (true);
SumLatticeDefault lattice = new SumLatticeDefault (transducer, seq); // used to have third argument: true
double oldWeight = lattice.getTotalWeight ();
System.out.println ("State 0 transition estimator");
Multinomial.Estimator est
= ((FeatureTransducer.State)transducer.getState(0)).getTransitionEstimator();
est.print();
assertTrue (est.getCount(0) == 2.0);
assertTrue (est.getCount(1) == 1.0);
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:13,代码来源:TestFeatureTransducer.java
示例10: Estimator
import cc.mallet.types.Multinomial; //导入依赖的package包/类
public Estimator (Collection<Multinomial> multinomialsTraining)
{
this.multinomials = new ArrayList<Multinomial>(multinomialsTraining);
for (int i = 1; i < multinomials.size(); i++)
if (((Multinomial)multinomials.get(i-1)).size()
!= ((Multinomial)multinomials.get(i)).size()
|| ((Multinomial)multinomials.get(i-1)).getAlphabet()
!= ((Multinomial)multinomials.get(i)).getAlphabet())
throw new IllegalArgumentException
("All multinomials must have same size and Alphabet.");
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:12,代码来源:Dirichlet.java
示例11: testEstimating
import cc.mallet.types.Multinomial; //导入依赖的package包/类
public void testEstimating ()
{
Alphabet dict = new Alphabet ();
Multinomial.Estimator e = new Multinomial.LaplaceEstimator (dict);
FeatureSequence fs = new FeatureSequence (dict);
fs.add (dict.lookupIndex ("a"));
fs.add (dict.lookupIndex ("n"));
fs.add (dict.lookupIndex ("d"));
fs.add (dict.lookupIndex ("r"));
fs.add (dict.lookupIndex ("e"));
fs.add (dict.lookupIndex ("w"));
fs.add (dict.lookupIndex ("m"));
fs.add (dict.lookupIndex ("c"));
fs.add (dict.lookupIndex ("c"));
fs.add (dict.lookupIndex ("a"));
fs.add (dict.lookupIndex ("l"));
fs.add (dict.lookupIndex ("l"));
fs.add (dict.lookupIndex ("u"));
fs.add (dict.lookupIndex ("m"));
//System.out.println (fs.toString());
e.increment (fs);
assertTrue (e.size() == 10);
Multinomial m = e.estimate ();
assertTrue (m.size() == 10);
assertTrue (m.probability (dict.lookupIndex ("a")) == (2.0+1)/(14.0+10));
assertTrue (m.probability ("w") == (1.0+1)/(14.0+10));
Multinomial.Logged ml = new Multinomial.Logged (m);
assertTrue (m.logProbability ("w") == ml.logProbability ("w"));
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:31,代码来源:TestMultinomial.java
示例12: estimateFeatureMultinomials
import cc.mallet.types.Multinomial; //导入依赖的package包/类
private Multinomial[] estimateFeatureMultinomials () {
int numLabels = targetAlphabet.size();
Multinomial[] m = new Multinomial[numLabels];
for (int li = 0; li < numLabels; li++) {
//me[li].print (); // debugging
m[li] = me[li].estimate();
}
return m;
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:10,代码来源:NaiveBayesTrainer.java
示例13: readObject
import cc.mallet.types.Multinomial; //导入依赖的package包/类
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
int version = in.readInt();
if (version != CURRENT_SERIAL_VERSION)
throw new ClassNotFoundException("Mismatched NaiveBayesTrainer versions: wanted " +
CURRENT_SERIAL_VERSION + ", got " +
version);
//default selections for the kind of Estimator used
featureEstimator = (Multinomial.Estimator) in.readObject();
priorEstimator = (Multinomial.Estimator) in.readObject();
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:12,代码来源:NaiveBayesEMTrainer.java
注:本文中的cc.mallet.types.Multinomial类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论