当前位置: 首页>>代码示例>>Java>>正文


Java ModelReader.readModel方法代码示例

本文整理汇总了Java中cc.mallet.grmm.util.ModelReader.readModel方法的典型用法代码示例。如果您正苦于以下问题:Java ModelReader.readModel方法的具体用法?Java ModelReader.readModel怎么用?Java ModelReader.readModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.mallet.grmm.util.ModelReader的用法示例。


在下文中一共展示了ModelReader.readModel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testContinousSample

import cc.mallet.grmm.util.ModelReader; //导入方法依赖的package包/类
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);
  }

  Variable x1 = fg.findVariable ("x1");
  Assignment assn1 = (Assignment) allAssn.marginalize (x1);
  int[] col = assn1.getColumnInt (x1);
  double mean = MatrixOps.sum (col) / ((double)col.length);
  assertEquals (0.5, mean, 0.025);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:18,代码来源:TestFactorGraph.java

示例2: testContinousSample2

import cc.mallet.grmm.util.ModelReader; //导入方法依赖的package包/类
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);
  }

  Variable x1 = fg.findVariable ("x2");
  Assignment assn1 = (Assignment) allAssn.marginalize (x1);
  int[] col = assn1.getColumnInt (x1);
  double mean = MatrixOps.sum (col) / ((double)col.length);
  assertEquals (0.5, mean, 0.01);

  Variable x2 = fg.findVariable ("x2");
  Assignment assn2 = (Assignment) allAssn.marginalize (x2);
  int[] col2 = assn2.getColumnInt (x2);
  double mean2 = MatrixOps.sum (col2) / ((double)col2.length);
  assertEquals (0.5, mean2, 0.025);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:24,代码来源:TestFactorGraph.java

示例3: testSliceInFg

import cc.mallet.grmm.util.ModelReader; //导入方法依赖的package包/类
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);
  fg2.dump ();
  assertEquals (2, fg2.factors ().size ());
  assertEquals (1.0/20, fg2.value (new Assignment ()), 1e-5);

  fg2.addFactor (new ConstantFactor (10.0));
  assertEquals (0.5, fg2.value (new Assignment ()), 1e-5);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:17,代码来源:TestUniformFactor.java

示例4: ignoretestContinousSample

import cc.mallet.grmm.util.ModelReader; //导入方法依赖的package包/类
public void ignoretestContinousSample () 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);
  }

  Variable x1 = fg.findVariable ("x1");
  Assignment assn1 = (Assignment) allAssn.marginalize (x1);
  int[] col = assn1.getColumnInt (x1);
  double mean = MatrixOps.sum (col) / ((double)col.length);
  assertEquals (0.5, mean, 0.025);
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:18,代码来源:TestFactorGraph.java

示例5: ignoretestContinousSample2

import cc.mallet.grmm.util.ModelReader; //导入方法依赖的package包/类
public void ignoretestContinousSample2 () 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);
  }

  Variable x1 = fg.findVariable ("x2");
  Assignment assn1 = (Assignment) allAssn.marginalize (x1);
  int[] col = assn1.getColumnInt (x1);
  double mean = MatrixOps.sum (col) / ((double)col.length);
  assertEquals (0.5, mean, 0.01);

  Variable x2 = fg.findVariable ("x2");
  Assignment assn2 = (Assignment) allAssn.marginalize (x2);
  int[] col2 = assn2.getColumnInt (x2);
  double mean2 = MatrixOps.sum (col2) / ((double)col2.length);
  assertEquals (0.5, mean2, 0.025);
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:24,代码来源:TestFactorGraph.java

示例6: testSliceInFg

import cc.mallet.grmm.util.ModelReader; //导入方法依赖的package包/类
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);
  assertEquals (2, fg2.factors ().size ());
  assertEquals (0.59261 * 1.13202, fg2.value (new Assignment ()), 1e-5);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:13,代码来源:TestBetaFactor.java

示例7: testAllFactorsOf

import cc.mallet.grmm.util.ModelReader; //导入方法依赖的package包/类
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 ());
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:10,代码来源:TestFactorGraph.java

示例8: ignoretestAllFactorsOf

import cc.mallet.grmm.util.ModelReader; //导入方法依赖的package包/类
public void ignoretestAllFactorsOf () 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 ());
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:10,代码来源:TestFactorGraph.java


注:本文中的cc.mallet.grmm.util.ModelReader.readModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。