Package edu.pitt.csb.mgm
Class Mgm
java.lang.Object
edu.pitt.csb.mgm.ConvexProximal
edu.pitt.csb.mgm.Mgm
- All Implemented Interfaces:
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncern.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.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.search()
Simple search command for GraphSearch implementation.void
setParams
(Mgm.MGMParams newParams) Setter for the fieldparams
.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.
-
Constructor Details
-
Mgm
-
Mgm
-
-
Method Details
-
flatten
public static cern.colt.matrix.DoubleMatrix1D flatten(cern.colt.matrix.DoubleMatrix2D m) flatten.
- Parameters:
m
- aDoubleMatrix2D
object- Returns:
- a
DoubleMatrix1D
object
-
upperTri
public static cern.colt.matrix.DoubleMatrix2D upperTri(cern.colt.matrix.DoubleMatrix2D mat, int di) upperTri.
- Parameters:
mat
- aDoubleMatrix2D
objectdi
- a int- Returns:
- a
DoubleMatrix2D
object
-
main
-
setParams
Setter for the field
params
.- Parameters:
newParams
- aMgm.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 classConvexProximal
- Parameters:
parIn
- input VectorgradOutVec
- 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 operatorX
- 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 classConvexProximal
- Parameters:
t
- the positive parameter for the prox operatorX
- the input vectorpX
- 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 functioniterLimit
- 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 intedgeChangeTol
- a int
-
graphFromMGM
-
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
Simple search command for GraphSearch implementation. Uses default edge convergence, 1000 iter limit.- Specified by:
search
in interfaceIGraphSearch
- Returns:
- a
Graph
object
-
getElapsedTime
public long getElapsedTime()Return time of execution for learning.- Returns:
- a long
-