Package cc.mallet.types

Examples of cc.mallet.types.Multinomial$LaplaceEstimator


    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);
  }
View Full Code Here


   * @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
View Full Code Here

  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);
    }
  }
View Full Code Here

      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);
      }
      initialEstimator = new Multinomial.LaplaceEstimator(
          transitionAlphabet);
View Full Code Here

    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"));
  }
View Full Code Here

    private void estimate ()
    {
      if (transitionCounts == null)
        throw new IllegalStateException ("Transducer is not currently trainable.");
      Multinomial transitionDistribution = transitionCounts.estimate ();
      for (int i = 0; i < transitions.length; i++)
        transitions[i].weight = transitionDistribution.logProbability (i);
    }
View Full Code Here

    return pr;
  }

  public Multinomial randomMultinomial (Randoms r)
  {
    return new Multinomial (randomRawMultinomial(r), dict, partition.length, false, false);
  }
View Full Code Here

    return new Dirichlet (pr, dict);
  }

  public FeatureSequence randomFeatureSequence (Randoms r, int length)
  {
    Multinomial m = randomMultinomial (r);
    return m.randomFeatureSequence (r, length);
  }
View Full Code Here

  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 ();
    }
  }
View Full Code Here

    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;
  }
View Full Code Here

TOP

Related Classes of cc.mallet.types.Multinomial$LaplaceEstimator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.