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.
Version:
$Id: $Id
Author:
josephramsey
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    The parameters of the MGM model.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Mgm(cern.colt.matrix.DoubleMatrix2D x, cern.colt.matrix.DoubleMatrix2D y, List<Node> variables, int[] l, double[] lambda)
    Constructor for Mgm.
    Mgm(DataSet ds, double[] lambda)
    Constructor for Mgm.
  • 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)
    flatten.
    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)
    main.
    double
    nonSmooth(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX)
    Calculates the non-smooth value for a given parameter and input vectors.
    double
    nonSmoothValue(cern.colt.matrix.DoubleMatrix1D parIn)
    Calculates the non-smooth value for the given input vector.
    cern.colt.matrix.DoubleMatrix1D
    proximalOperator(double t, cern.colt.matrix.DoubleMatrix1D X)
    Applies proximal operator on the given input vector with a positive parameter.
    Simple search command for GraphSearch implementation.
    void
    Setter for the field params.
    double
    smooth(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec)
    Smooth method calculates the smooth loss and gradient given input parameters.
    cern.colt.matrix.DoubleMatrix1D
    smoothGradient(cern.colt.matrix.DoubleMatrix1D parIn)
    Calculates the smooth gradient for a given input vector.
    double
    smoothValue(cern.colt.matrix.DoubleMatrix1D parIn)
    Calculate the smooth value of the given input vector.
    static cern.colt.matrix.DoubleMatrix2D
    upperTri(cern.colt.matrix.DoubleMatrix2D mat, int di)
    upperTri.

    Methods inherited from class java.lang.Object

    equals, 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)

      Constructor for Mgm.

      Parameters:
      x - a DoubleMatrix2D object
      y - a DoubleMatrix2D object
      variables - a List object
      l - an array of int objects
      lambda - an array of double objects
    • Mgm

      public Mgm(DataSet ds, double[] lambda)

      Constructor for Mgm.

      Parameters:
      ds - a DataSet object
      lambda - an array of double objects
  • Method Details

    • flatten

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

      flatten.

      Parameters:
      m - a DoubleMatrix2D object
      Returns:
      a DoubleMatrix1D object
    • upperTri

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

      upperTri.

      Parameters:
      mat - a DoubleMatrix2D object
      di - a int
      Returns:
      a DoubleMatrix2D object
    • main

      public static void main(String[] args)

      main.

      Parameters:
      args - an array of String objects
    • setParams

      public void setParams(Mgm.MGMParams newParams)

      Setter for the field params.

      Parameters:
      newParams - a Mgm.MGMParams object
    • smoothValue

      public double smoothValue(cern.colt.matrix.DoubleMatrix1D parIn)
      Calculate the smooth value of the given input vector.
      Parameters:
      parIn - The input vector.
      Returns:
      The smooth value.
    • smooth

      public double smooth(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec)
      Smooth method calculates the smooth loss and gradient given input parameters.
      Overrides:
      smooth in class ConvexProximal
      Parameters:
      parIn - input Vector
      gradOutVec - gradient of g(X)
      Returns:
      the smooth loss
    • nonSmoothValue

      public double nonSmoothValue(cern.colt.matrix.DoubleMatrix1D parIn)
      Calculates the non-smooth value for the given input vector.
      Parameters:
      parIn - the input vector
      Returns:
      the non-smooth value
    • smoothGradient

      public cern.colt.matrix.DoubleMatrix1D smoothGradient(cern.colt.matrix.DoubleMatrix1D parIn)
      Calculates the smooth gradient for a given input vector.
      Parameters:
      parIn - the input vector
      Returns:
      the smooth gradient
    • proximalOperator

      public cern.colt.matrix.DoubleMatrix1D proximalOperator(double t, cern.colt.matrix.DoubleMatrix1D X)
      Applies proximal operator on the given input vector with a positive parameter.
      Parameters:
      t - the positive parameter for proximal operator
      X - the input vector
      Returns:
      the result of applying proximal operator on the input vector
      Throws:
      IllegalArgumentException - if t is not positive
    • nonSmooth

      public double nonSmooth(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX)
      Calculates the non-smooth value for a given parameter and input vectors.
      Overrides:
      nonSmooth in class ConvexProximal
      Parameters:
      t - the positive parameter for the prox operator
      X - the input vector
      pX - the vector solution to prox_t(X)
      Returns:
      the non-smooth value
    • 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 - a int
    • 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 - a int
      edgeChangeTol - a int
    • graphFromMGM

      public Graph graphFromMGM()
      Converts MGM object to Graph object with edges if edge parameters are non-zero. Loses all edge param information
      Returns:
      a Graph object
    • 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:
      a DoubleMatrix2D object
    • search

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

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