Class Mgm

All Implemented Interfaces:
IGraphSearch

public class Mgm extends ConvexProximal implements IGraphSearch
Implementation of Lee and Hastie's (2012) pseudolikelihood method for learning Mixed Gaussian-Categorical Graphical Models Created by ajsedgewick on 7/15/15.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Mgm(cern.colt.matrix.DoubleMatrix2D x, cern.colt.matrix.DoubleMatrix2D y, List<Node> variables, int[] l, double[] lambda)
     
    Mgm(DataSet ds, double[] lambda)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    cern.colt.matrix.DoubleMatrix2D
    Converts MGM to matrix of doubles.
    static cern.colt.matrix.DoubleMatrix1D
    flatten(cern.colt.matrix.DoubleMatrix2D m)
     
    long
    Return time of execution for learning.
    Converts MGM object to Graph object with edges if edge parameters are non-zero.
    void
    learn(double epsilon, int iterLimit)
    Learn MGM traditional way with objective function tolerance.
    void
    learnEdges(int iterLimit)
    Learn MGM using edge convergence using default 3 iterations of no edge changes.
    void
    learnEdges(int iterLimit, int edgeChangeTol)
    Learn MGM using edge convergence using edgeChangeTol (see ProximalGradient for documentation).
    static void
    main(String[] args)
     
    double
    nonSmooth(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX)
    Calculates penalty term and proximal operator at the same time for speed
    double
    nonSmoothValue(cern.colt.matrix.DoubleMatrix1D parIn)
    Calculates penalty term of objective function
    cern.colt.matrix.DoubleMatrix1D
    proximalOperator(double t, cern.colt.matrix.DoubleMatrix1D X)
    A proximal operator for the MGM
    Simple search command for GraphSearch implementation.
    void
     
    double
    smooth(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec)
    non-penalized -log(pseudolikelihood) this is the smooth function g(x) in prox gradient this overloaded version calculates both nll and the smooth gradient at the same time any value in gradOut will be replaced by the new calculations
    cern.colt.matrix.DoubleMatrix1D
    smoothGradient(cern.colt.matrix.DoubleMatrix1D parIn)
    Gradient of the pseudolikelihood
    double
    smoothValue(cern.colt.matrix.DoubleMatrix1D parIn)
    non-penalized -log(pseudolikelihood) this is the smooth function g(x) in prox gradient
    static cern.colt.matrix.DoubleMatrix2D
    upperTri(cern.colt.matrix.DoubleMatrix2D mat, int di)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Mgm

      public Mgm(cern.colt.matrix.DoubleMatrix2D x, cern.colt.matrix.DoubleMatrix2D y, List<Node> variables, int[] l, double[] lambda)
    • Mgm

      public Mgm(DataSet ds, double[] lambda)
  • Method Details

    • flatten

      public static cern.colt.matrix.DoubleMatrix1D flatten(cern.colt.matrix.DoubleMatrix2D m)
    • upperTri

      public static cern.colt.matrix.DoubleMatrix2D upperTri(cern.colt.matrix.DoubleMatrix2D mat, int di)
    • main

      public static void main(String[] args)
    • setParams

      public void setParams(Mgm.MGMParams newParams)
    • smoothValue

      public double smoothValue(cern.colt.matrix.DoubleMatrix1D parIn)
      non-penalized -log(pseudolikelihood) this is the smooth function g(x) in prox gradient
      Parameters:
      parIn -
      Returns:
    • smooth

      public double smooth(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec)
      non-penalized -log(pseudolikelihood) this is the smooth function g(x) in prox gradient this overloaded version calculates both nll and the smooth gradient at the same time any value in gradOut will be replaced by the new calculations
      Overrides:
      smooth in class ConvexProximal
      Parameters:
      parIn -
      gradOutVec -
      Returns:
    • nonSmoothValue

      public double nonSmoothValue(cern.colt.matrix.DoubleMatrix1D parIn)
      Calculates penalty term of objective function
      Parameters:
      parIn -
      Returns:
    • smoothGradient

      public cern.colt.matrix.DoubleMatrix1D smoothGradient(cern.colt.matrix.DoubleMatrix1D parIn)
      Gradient of the pseudolikelihood
      Parameters:
      parIn -
      Returns:
    • proximalOperator

      public cern.colt.matrix.DoubleMatrix1D proximalOperator(double t, cern.colt.matrix.DoubleMatrix1D X)
      A proximal operator for the MGM
      Parameters:
      t - parameter for operator, must be positive
      X - input vector to operator
      Returns:
      output vector, same dimension as X
    • nonSmooth

      public double nonSmooth(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX)
      Calculates penalty term and proximal operator at the same time for speed
      Overrides:
      nonSmooth in class ConvexProximal
      Parameters:
      t - proximal operator parameter
      X - input
      pX - prox operator solution
      Returns:
      value of penalty term
    • learn

      public void learn(double epsilon, int iterLimit)
      Learn MGM traditional way with objective function tolerance. Recommended for inference applications that need accurate pseudolikelihood
      Parameters:
      epsilon - tolerance in change of objective function
      iterLimit - iteration limit
    • learnEdges

      public void learnEdges(int iterLimit)
      Learn MGM using edge convergence using default 3 iterations of no edge changes. Recommended when we only care about edge existence.
      Parameters:
      iterLimit -
    • learnEdges

      public void learnEdges(int iterLimit, int edgeChangeTol)
      Learn MGM using edge convergence using edgeChangeTol (see ProximalGradient for documentation). Recommended when we only care about edge existence.
      Parameters:
      iterLimit -
      edgeChangeTol -
    • graphFromMGM

      public Graph graphFromMGM()
      Converts MGM object to Graph object with edges if edge parameters are non-zero. Loses all edge param information
      Returns:
    • adjMatFromMGM

      public cern.colt.matrix.DoubleMatrix2D adjMatFromMGM()
      Converts MGM to matrix of doubles. uses 2-norm to combine c-d edge parameters into single value and f-norm for d-d edge parameters.
      Returns:
    • search

      public Graph search()
      Simple search command for GraphSearch implementation. Uses default edge convergence, 1000 iter limit.
      Specified by:
      search in interface IGraphSearch
      Returns:
    • getElapsedTime

      public long getElapsedTime()
      Return time of execution for learning.
      Returns: