Package cc.mallet.grmm.util

Examples of cc.mallet.grmm.util.ModelReader


          "u1 ~ Uniform 0.0 10.0\n" +
          "u2 ~ Uniform 5.0 7.0\n";

  public void testSliceInFg () throws IOException
  {
    ModelReader reader = new ModelReader ();
    FactorGraph fg = reader.readModel (new BufferedReader (new StringReader (mdlstr)));
    Variable u1 = fg.findVariable ("u1");
    Variable u2 = fg.findVariable ("u2");
    Assignment assn = new Assignment (new Variable[] { u1, u2 }, new double[] { 6.0, 6.0 });

    FactorGraph fg2 = (FactorGraph) fg.slice (assn);
View Full Code Here


          "u1 ~ Beta 0.2 0.7\n" +
          "u2 ~ Beta 1.0 0.3\n";

  public void testSliceInFg () throws IOException
  {
    ModelReader reader = new ModelReader ();
    FactorGraph fg = reader.readModel (new BufferedReader (new StringReader (TestBetaFactor.mdlstr)));
    Variable u1 = fg.findVariable ("u1");
    Variable u2 = fg.findVariable ("u2");
    Assignment assn = new Assignment (new Variable[] { u1, u2 }, new double[] { 0.25, 0.85 });

    FactorGraph fg2 = (FactorGraph) fg.slice (assn);
View Full Code Here

          "x1 ~ Unary u1\n" +
          "x2 ~ Unary u2\n";

  public void testContinousSample () throws IOException
  {
    ModelReader reader = new ModelReader ();
    FactorGraph fg = reader.readModel (new BufferedReader (new StringReader (uniformMdlstr)));
    Randoms r = new Randoms (324143);
    Assignment allAssn = new Assignment ();
    for (int i = 0; i < 10000; i++) {
      Assignment row = fg.sample (r);
      allAssn.addRow (row);
View Full Code Here

          "x1 ~ Unary u1\n" +
          "x2 ~ Unary u2\n";

  public void testContinousSample2 () throws IOException
  {
    ModelReader reader = new ModelReader ();
    FactorGraph fg = reader.readModel (new BufferedReader (new StringReader (uniformMdlstr2)));
    Randoms r = new Randoms (324143);
    Assignment allAssn = new Assignment ();
    for (int i = 0; i < 10000; i++) {
      Assignment row = fg.sample (r);
      allAssn.addRow (row);
View Full Code Here

    assertEquals (0.5, mean2, 0.025);
  }

  public void testAllFactorsOf () throws IOException
  {
    ModelReader reader = new ModelReader ();
    FactorGraph fg = reader.readModel (new BufferedReader (new StringReader (uniformMdlstr2)));
    Variable var = new Variable (2);
    var.setLabel ("v0");
    List lst = fg.allFactorsOf (var);
    assertEquals (0, lst.size ());
  }
View Full Code Here

          "x01 x11 ~ Potts alpha\n" +
          "x10 x11 ~ Potts alpha\n";

  public void testJtConstant () throws IOException
  {
    FactorGraph masterFg = new ModelReader ().readModel (new BufferedReader (new StringReader (gridStr)));
    JunctionTreeInferencer jt = new JunctionTreeInferencer ();
    Assignment assn = masterFg.sampleContinuousVars (new cc.mallet.util.Randoms (3214));
    FactorGraph fg = (FactorGraph) masterFg.slice (assn);
    jt.computeMarginals (fg);
  }
View Full Code Here

  "var2 ~ Unary 0.75\n" +
  "var3 ~ Unary 0.1\n";
   public static void main (String[] args) throws Exception {
       BufferedReader r = new BufferedReader (new StringReader (mdlExample));
       FactorGraph fg = new ModelReader().readModel (r);
       fg.dump();

       Inferencer inf = new JunctionTreeInferencer();
       inf.computeMarginals (fg);
       for (int vi = 0; vi < 4; vi++) {
View Full Code Here

TOP

Related Classes of cc.mallet.grmm.util.ModelReader

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.