cc.mallet.grmm.util
Class Models

java.lang.Object
  extended by cc.mallet.grmm.util.Models

public class Models
extends java.lang.Object

Static utilities that do useful things with factor graphs. Created: Sep 22, 2005

Version:
$Id: Models.java,v 1.1 2007/10/22 21:37:58 mccallum Exp $
Author:
Constructor Summary
Models()
           
 
Method Summary
static FactorGraph addEvidence(FactorGraph mdl, Assignment assn)
          Returns a new factor graph, the same as a given one, except that all the nodes in the given Assignment are clamped as evidence.
static FactorGraph addEvidence(FactorGraph mdl, Assignment assn, java.util.Map toSlicedMap)
           
static UndirectedModel addEvidence(UndirectedModel mdl, Assignment assn)
           
static Assignment bestAssignment(FactorGraph mdl, Inferencer inf)
          Returns the highest-score Assignment in a model according to a given inferencer.
static double entropy(FactorGraph mdl)
          Computes the exact entropy of a factor graph distribution using the junction tree algorithm.
static double KL(FactorGraph mdl1, FactorGraph mdl2)
          Computes the KL divergence KL(mdl1||mdl2).
static void removeConstantFactors(FactorGraph sliced)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Models

public Models()
Method Detail

addEvidence

public static FactorGraph addEvidence(FactorGraph mdl,
                                      Assignment assn)
Returns a new factor graph, the same as a given one, except that all the nodes in the given Assignment are clamped as evidence.

Parameters:
mdl - Old model. Will not be modified.
assn - Evidence to add
Returns:
A new factor graph.

addEvidence

public static FactorGraph addEvidence(FactorGraph mdl,
                                      Assignment assn,
                                      java.util.Map toSlicedMap)

addEvidence

public static UndirectedModel addEvidence(UndirectedModel mdl,
                                          Assignment assn)

bestAssignment

public static Assignment bestAssignment(FactorGraph mdl,
                                        Inferencer inf)
Returns the highest-score Assignment in a model according to a given inferencer.

Parameters:
mdl - Factor graph to use
inf - Inferencer to use. No need to call computeMarginals first.
Returns:
An Assignment

entropy

public static double entropy(FactorGraph mdl)
Computes the exact entropy of a factor graph distribution using the junction tree algorithm. If the model is intractable, then this method won't return a number anytime soon.


KL

public static double KL(FactorGraph mdl1,
                        FactorGraph mdl2)
Computes the KL divergence KL(mdl1||mdl2). Junction tree is used to compute the entropy.

TODO: This probably won't handle when the jnuction tree for MDL2 contains a clique that's not present in the junction tree for mdl1. If so, this is a bug.

Parameters:
mdl1 -
mdl2 -
Returns:
KL(mdl1||mdl2)

removeConstantFactors

public static void removeConstantFactors(FactorGraph sliced)