Package cc.mallet.types

Examples of cc.mallet.types.Dirichlet$Estimator


  private DirectedModel createDirectedModel ()
  {
    int NUM_OUTCOMES = 2;
    cc.mallet.util.Randoms random = new cc.mallet.util.Randoms (13413);

    Dirichlet dirichlet = new Dirichlet (NUM_OUTCOMES, 1.0);
    double[] pA = dirichlet.randomVector (random);
    double[] pB = dirichlet.randomVector (random);

    TDoubleArrayList pC = new TDoubleArrayList (NUM_OUTCOMES * NUM_OUTCOMES * NUM_OUTCOMES);
    for (int i = 0; i < (NUM_OUTCOMES * NUM_OUTCOMES); i++) {
      pC.add (dirichlet.randomVector (random));
    }

    Variable[] vars = new Variable[] { new Variable (NUM_OUTCOMES), new Variable (NUM_OUTCOMES),
            new Variable (NUM_OUTCOMES) };
    DirectedModel mdl = new DirectedModel ();
View Full Code Here


    reset ();
  }

  public RandomFeatureVectorIterator (Randoms r, Alphabet vocab, String[] classnames)
  {
    this (r, new Dirichlet(vocab, 2.0),
          30, 0,
          10, 20, classnames);
  }
View Full Code Here

    return ret;
  }

  public RandomFeatureVectorIterator (Randoms r, int vocabSize, int numClasses)
  {
    this (r, new Dirichlet(dictOfSize(vocabSize), 2.0),
          30, 0,
          10, 20, classNamesOfSize(numClasses));
  }
View Full Code Here

    reset ();
  }

  public RandomTokenSequenceIterator (Randoms r, Alphabet vocab, String[] classnames)
  {
    this (r, new Dirichlet(vocab, 2.0),
          30, 0,
          10, 20, classnames);
  }
View Full Code Here

    return ret;
  }

  public RandomTokenSequenceIterator (Randoms r, int vocabSize, int numClasses)
  {
    this (r, new Dirichlet(dictOfSize(vocabSize), 2.0),
          30, 0,
          10, 20, classNamesOfSize(numClasses));
  }
View Full Code Here

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

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

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

TOP

Related Classes of cc.mallet.types.Dirichlet$Estimator

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.